Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into android
Browse files Browse the repository at this point in the history
  • Loading branch information
Velaron committed Sep 15, 2023
2 parents 16f00f9 + bee35a1 commit 71da892
Show file tree
Hide file tree
Showing 32 changed files with 215 additions and 2,105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
targetos: win32
targetarch: i386
env:
SDL_VERSION: 2.26.2
SDL_VERSION: 2.28.1
GH_CPU_ARCH: ${{ matrix.targetarch }}
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/mainui
4 changes: 2 additions & 2 deletions engine/client/cl_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void CL_ScreenShot_f( void )
if( !CL_ScreenshotGetName( i, checkname, sizeof( checkname )))
return; // no namespace

if( !FS_FileExists( checkname, false ))
if( !FS_FileExists( checkname, true ))
break;
}

Expand Down Expand Up @@ -246,7 +246,7 @@ void CL_SnapShot_f( void )
if( !CL_SnapshotGetName( i, checkname, sizeof( checkname )))
return; // no namespace

if( !FS_FileExists( checkname, false ))
if( !FS_FileExists( checkname, true ))
break;
}

Expand Down
17 changes: 8 additions & 9 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ GNU General Public License for more details.
#include "library.h"
#include "vid_common.h"
#include "pm_local.h"
#include "sequence.h"

#define MAX_TOTAL_CMDS 32
#define MAX_CMD_BUFFER 8000
Expand Down Expand Up @@ -83,10 +82,10 @@ CVAR_DEFINE_AUTO( ui_renderworld, "0", FCVAR_ARCHIVE, "render world when UI is v
//
// userinfo
//
static CVAR_DEFINE_AUTO( name, "player", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_PRINTABLEONLY, "player name" );
static CVAR_DEFINE_AUTO( model, "", FCVAR_USERINFO|FCVAR_ARCHIVE, "player model ('player' is a singleplayer model)" );
static CVAR_DEFINE_AUTO( topcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "player top color" );
static CVAR_DEFINE_AUTO( bottomcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "player bottom color" );
static CVAR_DEFINE_AUTO( name, "player", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_PRINTABLEONLY|FCVAR_FILTERABLE, "player name" );
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" );

client_t cl;
Expand Down Expand Up @@ -233,9 +232,6 @@ void CL_SignonReply( void )
if( cl.proxy_redirect && !cls.spectator )
CL_Disconnect();
cl.proxy_redirect = false;

if( cls.demoplayback )
Sequence_OnLevelLoad( clgame.mapname );
break;
}
}
Expand Down Expand Up @@ -1559,6 +1555,8 @@ void CL_LocalServers_f( void )
{
netadr_t adr;

memset( &adr, 0, sizeof( adr ));

Con_Printf( "Scanning for servers on the local network area...\n" );
NET_Config( true, true ); // allow remote

Expand Down Expand Up @@ -1591,7 +1589,9 @@ size_t CL_BuildMasterServerScanRequest( char *buf, size_t size, qboolean nat )

info[0] = 0;

#ifndef XASH_ALL_SERVERS
Info_SetValueForKey( info, "gamedir", GI->gamefolder, remaining );
#endif
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining ); // let master know about client version
Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining );

Expand Down Expand Up @@ -3138,7 +3138,6 @@ void CL_Init( void )
VID_Init(); // init video
S_Init(); // init sound
Voice_Init( VOICE_DEFAULT_CODEC, 3 ); // init voice
Sequence_Init();

// unreliable buffer. unsed for unreliable commands and voice stream
MSG_Init( &cls.datagram, "cls.datagram", cls.datagram_buf, sizeof( cls.datagram_buf ));
Expand Down
10 changes: 4 additions & 6 deletions engine/client/cl_qparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,17 +694,13 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
cl_entity_t *ent;
int newnum;

memset( &state, 0, sizeof( state ));
newnum = MSG_ReadWord( msg ); // entnum

if( newnum >= clgame.maxEntities )
Host_Error( "CL_AllocEdict: no free edicts\n" );

ent = CL_EDICT_NUM( newnum );
memset( &ent->prevstate, 0, sizeof( ent->prevstate ));
ent->index = newnum;

// parse baseline
memset( &state, 0, sizeof( state ));
state.modelindex = MSG_ReadByte( msg );
state.frame = MSG_ReadByte( msg );
state.colormap = MSG_ReadByte( msg );
Expand All @@ -715,8 +711,10 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
state.angles[1] = MSG_ReadAngle( msg );
state.origin[2] = MSG_ReadCoord( msg );
state.angles[2] = MSG_ReadAngle( msg );
ent->player = CL_IsPlayerIndex( newnum );

ent = CL_EDICT_NUM( newnum );
ent->index = newnum;
ent->player = CL_IsPlayerIndex( newnum );
memcpy( &ent->baseline, &state, sizeof( entity_state_t ));
memcpy( &ent->prevstate, &state, sizeof( entity_state_t ));
}
Expand Down
6 changes: 5 additions & 1 deletion engine/client/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,9 +1754,13 @@ void Con_DrawDebug( void )

if( scr_download.value != -1.0f )
{
int length;
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
host.downloadcount, host.downloadfile, scr_download.value, Sys_DoubleTime() - timeStart );
x = refState.width - 500;

Con_DrawStringLen( dlstring, &length, NULL );
length = Q_max( length, 500 );
x = refState.width - length * 1.05f;
y = con.curFont->charHeight * 1.05f;
Con_DrawString( x, y, dlstring, g_color_table[7] );
}
Expand Down
20 changes: 3 additions & 17 deletions engine/client/s_vox.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ GNU General Public License for more details.
#include "common.h"
#include "sound.h"
#include "const.h"
#include "sequence.h"
#include <ctype.h>

static int cszrawsentences = 0;
Expand Down Expand Up @@ -165,24 +164,11 @@ static const char *VOX_LookupString( const char *pszin )
int i = -1, len;
const char *c;

// check if we are a CSCZ or immediate sentence
// check if we are an immediate sentence
if( *pszin == '#' )
{
// Q_atoi is too smart and allows negative values
// so check with Q_isdigit beforehand
if( Q_isdigit( pszin + 1 ))
{
sentenceEntry_s *sentenceEntry;
i = Q_atoi( pszin + 1 );
if(( sentenceEntry = Sequence_GetSentenceByIndex( i )))
return sentenceEntry->data;
return NULL;
}
else
{
// immediate sentence, probably coming from "speak" command
return pszin + 1;
}
// immediate sentence, probably coming from "speak" command
return pszin + 1;
}

// check if we received an index
Expand Down
5 changes: 2 additions & 3 deletions engine/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ GNU General Public License for more details.
#include "const.h"
#include "client.h"
#include "library.h"
#include "sequence.h"

static const char *file_exts[] =
{
Expand Down Expand Up @@ -1047,7 +1046,7 @@ void *GAME_EXPORT pfnSequenceGet( const char *fileName, const char *entryName )
{
Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName );

return Sequence_Get( fileName, entryName );
return NULL;
}

/*
Expand All @@ -1061,7 +1060,7 @@ void *GAME_EXPORT pfnSequencePickSentence( const char *groupName, int pickMethod
{
Msg( "Sequence_PickSentence: group %s, pickMethod %i\n", groupName, pickMethod );

return Sequence_PickSentence( groupName, pickMethod, picked );
return NULL;

}

Expand Down
2 changes: 1 addition & 1 deletion engine/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ void SV_ShutdownGame( void );
void SV_ExecLoadLevel( void );
void SV_ExecLoadGame( void );
void SV_ExecChangeLevel( void );
void SV_InitGameProgs( void );
qboolean SV_InitGameProgs( void );
void SV_FreeGameProgs( void );
void CL_WriteMessageHistory( void );
void CL_SendCmd( void );
Expand Down
8 changes: 6 additions & 2 deletions engine/common/con_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,12 +1423,14 @@ save serverinfo variables into server.cfg (using for dedicated server too)
*/
void GAME_EXPORT Host_WriteServerConfig( const char *name )
{
qboolean already_loaded;
file_t *f;
string newconfigfile;

Q_snprintf( newconfigfile, MAX_STRING, "%s.new", name );

SV_InitGameProgs(); // collect user variables
// TODO: remove this mechanism, make it safer for now
already_loaded = SV_InitGameProgs(); // collect user variables

// FIXME: move this out until menu parser is done
CSCR_LoadDefaultCVars( "settings.scr" );
Expand All @@ -1447,7 +1449,9 @@ void GAME_EXPORT Host_WriteServerConfig( const char *name )
}
else Con_DPrintf( S_ERROR "Couldn't write %s.\n", name );

SV_FreeGameProgs(); // release progs with all variables
// don't unload library that wasn't loaded by us
if( !already_loaded )
SV_FreeGameProgs(); // release progs with all variables
}

/*
Expand Down
6 changes: 3 additions & 3 deletions engine/common/crashhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context)
bp = (void**)ucontext->uc_mcontext.mc_ebp;
sp = (void**)ucontext->uc_mcontext.mc_esp;
#elif XASH_NETBSD
pc = (void*)ucontext->uc_mcontext.__gregs[REG_EIP];
bp = (void**)ucontext->uc_mcontext.__gregs[REG_EBP];
sp = (void**)ucontext->uc_mcontext.__gregs[REG_ESP];
pc = (void*)ucontext->uc_mcontext.__gregs[_REG_EIP];
bp = (void**)ucontext->uc_mcontext.__gregs[_REG_EBP];
sp = (void**)ucontext->uc_mcontext.__gregs[_REG_ESP];
#elif XASH_OPENBSD
pc = (void*)ucontext->sc_eip;
bp = (void**)ucontext->sc_ebp;
Expand Down
2 changes: 1 addition & 1 deletion engine/common/cvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const char *Cvar_ValidateString( convar_t *var, const char *value )
int len = 0;

// step through the string, only copying back in characters that are printable
while( *pszValue && len < MAX_STRING )
while( *pszValue && len < ( MAX_STRING - 1 ))
{
if( ((byte)*pszValue) < 32 )
{
Expand Down
59 changes: 58 additions & 1 deletion engine/common/ipv6text.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
{
// Next thing must be a quad, or end of input. Is it a quad?
int quadDigit = ParseIPv6Addr_HexDigitVal( *s );
const char *pszStartQuad;
int quad;

if ( quadDigit < 0 )
{
if ( bQuadMustFollow )
Expand All @@ -189,6 +191,7 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
if ( d >= pEndIP )
return false;

pszStartQuad = s;
++s;
quad = quadDigit;

Expand All @@ -214,6 +217,60 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
}
}

// Check if we hit a period, which would happen if we
// have an IPv4 dotted decimal. For example, "::ffff:192.168.1.210"
if ( *s == '.' )
{
// Make sure we would have room to store four more bytes.
unsigned char *pEndDottedDecimal = d+4;
if ( pEndDottedDecimal > pEndIP )
return false;

// Parse 4 octets
s = pszStartQuad;
for (;;)
{

// Parse 1-3 decimal digits
int octet = ParseIPv6Addr_DecimalDigitVal( *s );
int dig;

if ( octet < 0 )
return false;
++s;
dig = ParseIPv6Addr_DecimalDigitVal( *s );
if ( dig >= 0 )
{
++s;
octet = octet*10 + dig;
dig = ParseIPv6Addr_DecimalDigitVal( *s );
if ( dig >= 0 )
{
++s;
octet = octet*10 + dig;

// Make sure value is in range.
if ( octet > 255 )
return false;
}
}
*(d++) = (unsigned char)octet;

// All done?
if ( d >= pEndDottedDecimal )
break;

// Next thing must be dot dot separator
if ( *s != '.' )
return false;

// Eat dot
++s;
}

break;
}

// Stash it in the next slot, ignoring for now the issue
// of compressed zeros
*(d++) = (unsigned char)( quad >> 8 );
Expand Down Expand Up @@ -288,7 +345,7 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
int nScopeDigit;

++s;

nScopeDigit = ParseIPv6Addr_DecimalDigitVal( *s );
if ( nScopeDigit < 0 )
return false;
Expand Down
6 changes: 4 additions & 2 deletions engine/common/ipv6text.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ extern "C" {
extern void IPv6IPToString( char *pszOutText, const unsigned char *ip );

/// Format IPv6 IP and port to string. This uses the recommended
/// bracket notation, eg [1234::1]:12345. Your buffer must be
/// bracket notation, eg [1234::1]:12345. Your buffer MUST be
/// at least k_ncchMaxIPV6AddrStringWithPort bytes.
///
/// If the scope is zero, it is not printed.
extern void IPv6AddrToString( char *pszOutText, const unsigned char *ip, uint16_t port, uint32_t scope );

/// Parse IPv6 address string. Returns true if parsed OK. Returns false
Expand All @@ -41,7 +43,7 @@ extern void IPv6AddrToString( char *pszOutText, const unsigned char *ip, uint16_
///
/// Leading and trailing whitespace is OK around the entire string,
/// but not internal whitespace. The different methods for separating the
/// port in RFC5952 are supported section 6, except the ambiguous case
/// port in RFC5952 section 6 are supported, except the ambiguous case
/// of a colon to separate the port, when the IP contains a double-colon.
/// Brackets around an IP are OK, even if there is no port.
///
Expand Down
6 changes: 3 additions & 3 deletions engine/common/net_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ const char *NET_AdrToString( const netadr_t a )

if( a.type == NA_LOOPBACK )
return "loopback";
if( a.type6 == NA_IP6 )
if( a.type6 == NA_IP6 || a.type6 == NA_MULTICAST_IP6 )
{
uint8_t ip6[16];

Expand All @@ -750,7 +750,7 @@ const char *NET_BaseAdrToString( const netadr_t a )

if( a.type == NA_LOOPBACK )
return "loopback";
if( a.type6 == NA_IP6 )
if( a.type6 == NA_IP6 || a.type6 == NA_MULTICAST_IP6 )
{
uint8_t ip6[16];

Expand Down Expand Up @@ -1066,7 +1066,7 @@ net_gai_state_t NET_StringToAdrNB( const char *string, netadr_t *adr )
if( !Q_stricmp( string, "localhost" ) || !Q_stricmp( string, "loopback" ))
{
adr->type = NA_LOOPBACK;
return true;
return NET_EAI_OK;
}

res = NET_StringToSockaddr( string, &s, true, AF_UNSPEC );
Expand Down
Loading

0 comments on commit 71da892

Please sign in to comment.