Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into android-rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Velaron committed Mar 14, 2024
2 parents de7b317 + e039ef3 commit 85279b7
Show file tree
Hide file tree
Showing 65 changed files with 774 additions and 309 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/donate.md
2 changes: 1 addition & 1 deletion 3rdparty/gl4es/gl4es
2 changes: 1 addition & 1 deletion 3rdparty/nanogl
Submodule nanogl updated 3 files
+1 −0 GL/gl.h
+0 −207 GL/gl_entries.in
+47 −9 nanoWrap.cpp
25 changes: 25 additions & 0 deletions Documentation/extensions/native-object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# GetNativeObject API

To be able to use platform-specific features or get optional engine interfaces, we've added a simple call to MobilityAPI on client DLL and PhysicsAPI for server DLL and extended MenuAPI for menu DLL.

It's defined like this:

```
void *pfnGetNativeObject( const char *name );
```

#### Cross-platform objects

Only these objects are guaranteed to be available on all targets.

| Object name | Interface |
|-------------|-----------|
| `VFileSystem009` | Provides C++ interface to filesystem, binary-compatible with Valve's VFileSystem009. |
| `XashFileSystemXXX` | Provides C interface to filesystem. This interface is unstable and not recommended for generic use, outside of engine internals. For more info about current version look into `filesystem.h`. |

#### Android-specific objects

| Object name | Interface |
|-------------|-----------|
| `JNIEnv` | Allows interfacing with Java Native Interface. |
| `ActivityClass` | Returns JNI object for engine Android activity class. |
9 changes: 9 additions & 0 deletions common/com_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,5 +534,14 @@ typedef struct
#define MAX_EFRAGS 8192 // Arcane Dimensions required
#define MAX_REQUESTS 64

#if ! XASH_64BIT
STATIC_ASSERT( sizeof( mextrasurf_t ) == 324, "mextrasurf_t unexpected size" );
STATIC_ASSERT( sizeof( decal_t ) == 60, "decal_t unexpected size");
STATIC_ASSERT( sizeof( mfaceinfo_t ) == 176, "mfaceinfo_t unexpected size");
#else
STATIC_ASSERT( sizeof( mextrasurf_t) == 496, "mextrasurf_t unexpected size");
STATIC_ASSERT( sizeof( decal_t ) == 88, "decal_t unexpected size");
STATIC_ASSERT( sizeof( mfaceinfo_t ) == 304, "mfaceinfo_t unexpected size");
#endif

#endif//COM_MODEL_H
6 changes: 0 additions & 6 deletions common/xash3d_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,20 @@ typedef uint64_t longtime_t;
#define NORETURN __attribute__((noreturn))
#define NONNULL __attribute__((nonnull))
#define ALLOC_CHECK(x) __attribute__((alloc_size(x)))
#define FORCEINLINE inline __attribute__((always_inline))
#define NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER)
#define EXPORT __declspec( dllexport )
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#define ALLOC_CHECK(x)
#define FORCEINLINE __forceinline
#define NOINLINE __declspec( noinline )
#else
#define EXPORT
#define GAME_EXPORT
#define _format(x)
#define NORETURN
#define NONNULL
#define ALLOC_CHECK(x)
#define FORCEINLINE
#define NOINLINE
#endif

#if ( __GNUC__ >= 3 )
Expand Down
3 changes: 2 additions & 1 deletion engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,8 @@ pfnCvar_RegisterVariable
static cvar_t *GAME_EXPORT pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags )
{
// a1ba: try to mitigate outdated client.dll vulnerabilities
if( !Q_stricmp( szName, "motdfile" ))
if( !Q_stricmp( szName, "motdfile" )
|| !Q_stricmp( szName, "sensitivity" ))
flags |= FCVAR_PRIVILEGED;

return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
Expand Down
1 change: 1 addition & 0 deletions engine/client/cl_gameui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ static ui_extendedfuncs_t gExtendedfuncs =
pfnParseFileSafe,
NET_AdrToString,
NET_CompareAdrSort,
Sys_GetNativeObject,
};

void UI_UnloadProgs( void )
Expand Down
43 changes: 32 additions & 11 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ GNU General Public License for more details.
#define MAX_CMD_BUFFER 8000
#define CONNECTION_PROBLEM_TIME 15.0 // 15 seconds
#define CL_CONNECTION_RETRIES 10
#define CL_TEST_RETRIES_NORESPONCE 3
#define CL_TEST_RETRIES 5

CVAR_DEFINE_AUTO( mp_decals, "300", FCVAR_ARCHIVE, "decals limit in multiplayer" );
Expand Down Expand Up @@ -75,8 +74,9 @@ static CVAR_DEFINE_AUTO( cl_upmax, "1200", FCVAR_ARCHIVE, "max allowed incoming

CVAR_DEFINE_AUTO( cl_lw, "1", FCVAR_ARCHIVE|FCVAR_USERINFO, "enable client weapon predicting" );
CVAR_DEFINE_AUTO( cl_charset, "utf-8", FCVAR_ARCHIVE, "1-byte charset to use (iconv style)" );
CVAR_DEFINE_AUTO( cl_trace_messages, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable message names tracing (good for developers)");
CVAR_DEFINE_AUTO( cl_trace_events, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable events tracing (good for developers)");
CVAR_DEFINE_AUTO( cl_trace_stufftext, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable stufftext (server-to-client console commands) tracing (good for developers)" );
CVAR_DEFINE_AUTO( cl_trace_messages, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable message names tracing (good for developers)" );
CVAR_DEFINE_AUTO( cl_trace_events, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable events tracing (good for developers)" );
static CVAR_DEFINE_AUTO( cl_nat, "0", 0, "show servers running under NAT" );
CVAR_DEFINE_AUTO( hud_utf8, "0", FCVAR_ARCHIVE, "Use utf-8 encoding for hud text" );
CVAR_DEFINE_AUTO( ui_renderworld, "0", FCVAR_ARCHIVE, "render world when UI is visible" );
Expand Down Expand Up @@ -1071,6 +1071,22 @@ static void CL_SendConnectPacket( void )
cls.timestart = Sys_DoubleTime();
}

/*
=================
CL_GetTestFragmentSize
Returns bandwidth test fragment size
=================
*/
static int CL_GetTestFragmentSize( void )
{
const int fragmentSizes[CL_TEST_RETRIES] = { 64000, 32000, 10666, 5200, 1400 };
if( cls.connect_retry >= 0 && cls.connect_retry < CL_TEST_RETRIES )
return bound( FRAGMENT_MIN_SIZE, fragmentSizes[cls.connect_retry], FRAGMENT_MAX_SIZE );
else
return FRAGMENT_MIN_SIZE;
}

/*
=================
CL_CheckForResend
Expand All @@ -1082,8 +1098,9 @@ static void CL_CheckForResend( void )
{
netadr_t adr;
net_gai_state_t res;
float resendTime;
qboolean bandwidthTest;

if( cls.internetservers_wait )
CL_SendMasterServerScanRequest();

Expand All @@ -1109,7 +1126,10 @@ static void CL_CheckForResend( void )
else if( cl_resend.value > CL_MAX_RESEND_TIME )
Cvar_SetValue( "cl_resend", CL_MAX_RESEND_TIME );

if(( host.realtime - cls.connect_time ) < cl_resend.value )
bandwidthTest = !cls.legacymode && cl_test_bandwidth.value && cls.connect_retry <= CL_TEST_RETRIES;
resendTime = bandwidthTest ? 1.0f : cl_resend.value;

if(( host.realtime - cls.connect_time ) < resendTime )
return;

res = NET_StringToAdrNB( cls.servername, &adr );
Expand All @@ -1136,27 +1156,27 @@ static void CL_CheckForResend( void )

if( adr.port == 0 ) adr.port = MSG_BigShort( PORT_SERVER );

if( cls.connect_retry == CL_TEST_RETRIES_NORESPONCE )
if( cls.connect_retry == CL_TEST_RETRIES )
{
// too many fails use default connection method
Con_Printf( "hi-speed connection is failed, use default method\n" );
Con_Printf( "Bandwidth test failed, fallback to default connecting method\n" );
Con_Printf( "Connecting to %s... (retry #%i)\n", cls.servername, cls.connect_retry + 1 );
Netchan_OutOfBandPrint( NS_CLIENT, adr, "getchallenge\n" );
Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE );
cls.connect_time = host.realtime;
cls.connect_retry++;
return;
}

bandwidthTest = !cls.legacymode && cl_test_bandwidth.value;
cls.serveradr = adr;
cls.max_fragment_size = Q_min( FRAGMENT_MAX_SIZE, cls.max_fragment_size / (cls.connect_retry + 1));
cls.max_fragment_size = CL_GetTestFragmentSize();
cls.connect_time = host.realtime; // for retransmit requests
cls.connect_retry++;

if( bandwidthTest )
Con_Printf( "Connecting to %s... [retry #%i, max fragment size %i]\n", cls.servername, cls.connect_retry, cls.max_fragment_size );
Con_Printf( "Connecting to %s... (retry #%i, fragment size %i)\n", cls.servername, cls.connect_retry, cls.max_fragment_size );
else
Con_Printf( "Connecting to %s... [retry #%i]\n", cls.servername, cls.connect_retry );
Con_Printf( "Connecting to %s... (retry #%i)\n", cls.servername, cls.connect_retry );

if( bandwidthTest )
Netchan_OutOfBandPrint( NS_CLIENT, adr, "bandwidth %i %i\n", PROTOCOL_VERSION, cls.max_fragment_size );
Expand Down Expand Up @@ -2892,6 +2912,7 @@ static void CL_InitLocal( void )

Cvar_RegisterVariable( &rcon_address );

Cvar_RegisterVariable( &cl_trace_stufftext );
Cvar_RegisterVariable( &cl_trace_messages );
Cvar_RegisterVariable( &cl_trace_events );

Expand Down
7 changes: 7 additions & 0 deletions engine/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2329,11 +2329,18 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
break;
case svc_stufftext:
s = MSG_ReadString( msg );
if( cl_trace_stufftext.value )
{
size_t len = Q_strlen( s );
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
}

#ifdef HACKS_RELATED_HLMODS
// disable Cry Of Fear antisave protection
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
break; // too early
#endif

Cbuf_AddFilteredText( s );
break;
case svc_setangle:
Expand Down
8 changes: 6 additions & 2 deletions engine/client/cl_parse_48.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,17 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
break;
case svc_stufftext:
s = MSG_ReadString( msg );
if( cl_trace_stufftext.value )
{
size_t len = Q_strlen( s );
Con_Printf( "Stufftext: %s%c", s, len && s[len-1] == '\n' ? '\0' : '\n' );
}

#ifdef HACKS_RELATED_HLMODS
// disable Cry Of Fear antisave protection
if( !Q_strnicmp( s, "disconnect", 10 ) && cls.signon != SIGNONS )
break; // too early
#endif

Con_Reportf( "Stufftext: %s", s );
Cbuf_AddFilteredText( s );
break;
case svc_setangle:
Expand Down
19 changes: 4 additions & 15 deletions engine/client/cl_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,25 +795,14 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const

pmove->player_index = ps->number - 1;

// a1ba: workaround bug on old protocol where the server refuse to send
// our local player in delta. cl.playernum, in theory, must be equal
// to our local player index anyway
// a1ba: workaround bug where the server refuse to send our local player in delta
// cl.playernum, in theory, must be equal to our local player index anyway
//
// this might not be a real solution, since everything else will be bogus
// but we need to properly run prediction and avoid potential memory
// corruption
// either debug this, or remove when old protocol will be dropped!!!
if( pmove->player_index < 0 )
{
if( cls.legacymode )
{
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
}
else
{
// if this happens, record a demo and send it to a1ba
Host_Error( "%s: ps->number == %d\n", __func__, ps->number );
}
}
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );

pmove->multiplayer = (cl.maxclients > 1);
pmove->runfuncs = runfuncs;
Expand Down
1 change: 1 addition & 0 deletions engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ extern convar_t r_showtextures;
extern convar_t cl_bmodelinterp;
extern convar_t cl_lw; // local weapons
extern convar_t cl_charset;
extern convar_t cl_trace_stufftext;
extern convar_t cl_trace_messages;
extern convar_t cl_trace_events;
extern convar_t hud_utf8;
Expand Down
54 changes: 35 additions & 19 deletions engine/client/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ Con_ClearField
*/
static void Con_ClearField( field_t *edit )
{
memset( edit->buffer, 0, MAX_STRING );
memset( edit->buffer, 0, sizeof( edit->buffer ));
edit->cursor = 0;
edit->scroll = 0;
}
Expand Down Expand Up @@ -1444,36 +1444,49 @@ static void Con_HistoryAppend( con_history_t *self, field_t *from )

static void Con_LoadHistory( con_history_t *self )
{
const byte *aFile = FS_LoadFile( "console_history.txt", NULL, true );
const char *pLine, *pFile;
int i, len;
field_t *f;
file_t *fd;
int i;

fd = FS_Open( "console_history.txt", "rb", true );

if( !aFile )
if( !fd )
return;

for( pFile = pLine = (char *)aFile; *pFile; pFile++ )
while( !FS_Eof( fd ))
{
if( *pFile != '\n' )
continue;

Con_ClearField( &self->lines[self->next] );

len = Q_min( pFile - pLine + 1, sizeof( f->buffer ));
f = &self->lines[self->next % CON_HISTORY];

Con_ClearField( f );
f->widthInChars = con.linewidth;
f->cursor = len - 1;
Q_strncpy( f->buffer, pLine, len);

self->next++;
FS_Gets( fd, f->buffer, sizeof( f->buffer ));
f->cursor = Q_strlen( f->buffer );

pLine = pFile + 1;
// skip empty lines
if( f->cursor == 0 )
continue;

// skip repeating lines
if( self->next > 0 )
{
field_t *prev;
prev = &self->lines[(self->next - 1) % CON_HISTORY];
if( !Q_stricmp( prev->buffer, f->buffer ))
continue;
}

self->next++;
}

FS_Close( fd );

for( i = self->next; i < CON_HISTORY; i++ )
{
Con_ClearField( &self->lines[i] );
self->lines[i].widthInChars = con.linewidth;
f = &self->lines[i];

Con_ClearField( f );
f->widthInChars = con.linewidth;
}

self->line = self->next;
Expand All @@ -1491,7 +1504,7 @@ static void Con_SaveHistory( con_history_t *self )
if( historyStart < 0 )
historyStart = 0;

f = FS_Open( "console_history.txt", "w", true );
f = FS_Open( "console_history.txt", "wb", true );

for( i = historyStart; i < self->next; i++ )
FS_Printf( f, "%s\n", self->lines[i % CON_HISTORY].buffer );
Expand Down Expand Up @@ -2100,6 +2113,9 @@ void Con_RunConsole( void )
// decide on the destination height of the console
if( host.allow_console && cls.key_dest == key_console )
{
#if XASH_MOBILE_PLATFORM
con.showlines = refState.height; // always full screen on mobile devices
#else
if( cls.state < ca_active || cl.first_frame )
con.showlines = refState.height; // full screen
#if XASH_MOBILE_PLATFORM
Expand Down
Loading

0 comments on commit 85279b7

Please sign in to comment.