Compare commits

...

51 Commits

Author SHA1 Message Date
SNMetamorph
ec5e9cb6e3 engine: client: send engine build information to masterserver 2024-06-10 20:53:59 +03:00
Alibek Omarov
f4b4546197 engine: temporarily fix loading studio models with split texture model 2024-06-10 14:57:00 +03:00
Alibek Omarov
f047749e61 engine: move studio model truncation into separate function, disable it by default 2024-06-10 13:34:02 +03:00
Alibek Omarov
87840ce91d engine: fix potential buffer overflow in Mod_StudioTexName
* Model names are 64 bytes wide, adding texture character means we needs 65 byte wide string.
* It never gets stored in memory anyway.
2024-06-10 13:28:01 +03:00
Alibek Omarov
bf31e9f634 engine: fix NO_ASAN macro usage with MSVC 2024-06-09 09:37:16 +03:00
Alibek Omarov
f86d84daed engine: platform: sdl: initialize window name string when building with old SDL 2024-06-09 09:16:45 +03:00
Alibek Omarov
41ed920d35 common: xash3d_types: fix build 2024-06-09 09:16:07 +03:00
Alibek Omarov
df23ddb545 engine: server: fix signed integer overflow in challenge generator 2024-06-09 07:05:24 +03:00
Alibek Omarov
767556ccad engine: temporarily disable ASan in MSG_WriteUBitLong (evil!) 2024-06-09 07:03:59 +03:00
Alibek Omarov
f9dab2ad19 engine: server: rename sv_allow_upload to sv_allowupload for compatibility 2024-06-09 07:02:50 +03:00
Alibek Omarov
66cb3a6120 engine: client: add room_off variable to toggle sound effects processing for GoldSrc compatibility
* Fixes Sven-Coop 4.8 client.
* Declare dsp_off deprecated.
2024-06-09 03:51:43 +03:00
Tuldok
7672a370da engine: Crashhandler support for Windows-on-ARM (arm/arm64) 2024-06-08 21:35:55 +03:00
Alibek Omarov
870e47ed03 engine: ensure character signness when checking for nonprintable characters 2024-06-07 22:22:13 +03:00
Alibek Omarov
32d4bdb80f engine: fix UTF-8 sequence input
Fixes: 2e0fc3e4c1 ("engine: client: do not repeatedly check cl_charset value, use generic Con_UtfProcessChar")
2024-06-07 22:16:32 +03:00
Alibek Omarov
929dfd2c71 mainui: update 2024-06-03 09:04:47 +03:00
Alibek Omarov
f437af6451 mainui: update 2024-06-03 07:57:10 +03:00
Alibek Omarov
413a0fb2e5 engine: client: improve accumulating rounding error, thanks @SNMetamorph for suggestion 2024-06-02 13:09:10 +03:00
Alibek Omarov
793adadb06 mainui: update 2024-06-02 12:51:30 +03:00
Alibek Omarov
999b43b89f engine: implement changing cursor type in gameui 2024-06-02 12:24:14 +03:00
Alibek Omarov
bd60c88c7d ref: soft: fix build with OpenMP under Visual Studio 2024-06-02 11:39:54 +03:00
Alibek Omarov
23b9a2eddf waf.bat: add checks for newer pythons, remove checks for pythons below 2.7 2024-06-02 11:39:54 +03:00
Alibek Omarov
0b57d97c8c vgui_support: update submodule 2024-06-02 11:35:57 +03:00
Alibek Omarov
6255293dd4 engine: fix using OpenMP PHS generation under Visual Studio 2024-06-02 10:34:10 +03:00
Alibek Omarov
04136d95a3 filesystem: fix build warning 2024-06-02 10:33:33 +03:00
Alibek Omarov
40aa29e42a ci: remove freebsd-13-2 task 2024-06-02 10:04:04 +03:00
Alibek Omarov
a709f30da9 engine: soundlib: libmpg: add wrappers on top of libc read & lseek in case they don't match internal mpg123 types
(we better migrate to upstream libmpg at some point)
2024-06-02 09:19:17 +03:00
Alibek Omarov
0796c14e79 engine: client: fix framerate depending player move 2024-06-02 04:15:17 +03:00
Alibek Omarov
a9c0a4be23 engine: server: add cvar to disable bandwidth test on server side 2024-06-01 05:27:35 +03:00
Alibek Omarov
3e1209d3a4 engine: client: do not rely on host.downloadcount when connecting to the server with HTTP enabled
* Replace cl.downloadUrl by cl.http_download
2024-06-01 04:30:21 +03:00
Alibek Omarov
caf14c1b7c engine: soundlib: libmpg: fix the inconsistent use of offset types in lseek() 2024-05-31 03:35:39 +03:00
Alibek Omarov
27f7d2c8d2 engine: common: ban few more executable types for COM_IsSafeFileToDownload 2024-05-31 00:43:28 +03:00
Alibek Omarov
8ee430eda2 engine: common: double check that resource starting with !MD5 doesn't have any extension 2024-05-31 00:42:44 +03:00
Alibek Omarov
484e4cb225 engine: common: net_ws: less verbose HTTP client, fix printing header size in case of an error 2024-05-31 00:07:14 +03:00
Alibek Omarov
b080ad9954 engine: moved link_t helpers to sv_world.c from world.c and made them static 2024-05-30 07:31:03 +03:00
Alibek Omarov
f6625d9188 engine: common: remove unused et_name array 2024-05-30 07:22:21 +03:00
Alibek Omarov
1eb2816bc4 engine: client: manually call FS_Rescan if we downloaded an archive while connecting to server 2024-05-30 06:48:17 +03:00
Alibek Omarov
077be5aaf3 engine: client: only strip DEFAULT_SOUNDPATH from t_sound resources 2024-05-30 06:47:46 +03:00
Alibek Omarov
d59875f114 engine: common: for automatic wad precache to work, we need to count the real wad usage on dedicated 2024-05-30 06:18:15 +03:00
Alibek Omarov
e89191ed39 engine: common: automatically precache wad files required by loaded map
Makes it easier to host server with multiplayer maps and broken .res files.
2024-05-30 05:58:41 +03:00
Alibek Omarov
ea21438637 engine: netchan: append .ztmp extension instead of replacing original extension
* so we don't send wrong file that has same name but different extension

* validate filename size so it won't get truncated in fragbuf_t
2024-05-30 04:50:58 +03:00
Alibek Omarov
0d2e8333e8 common: remove unused boneinfo.h header 2024-05-29 12:25:23 +03:00
Alibek Omarov
338399e622 engine: common: implement PHS calculation like in QuakeWorld/GoldSrc 2024-05-29 05:58:51 +03:00
Alibek Omarov
27cab8aad5 scripts: waifulib: compiler_optimizations: set HAVE_OPENMP=1 define if openmp feature was enabled during the build 2024-05-29 05:41:47 +03:00
Alibek Omarov
1545a49b4c engine: client: only allocate debug hulls polygons when they're requested
* Make the appropriate changes in ref_gl
2024-05-29 05:41:47 +03:00
Alibek Omarov
3ca15250e8 engine: common: use Mod_PointInLeaf in Mod_GetPVSForPoint instead of traversing nodes manually 2024-05-29 05:41:47 +03:00
Alibek Omarov
6cbac51731 engine: common: add function for compressing visdata 2024-05-29 05:41:47 +03:00
Alibek Omarov
e310c666b1 engine: common: add phs flag to Mod_FatPVS, unused currently 2024-05-29 05:41:47 +03:00
Alibek Omarov
677b0170aa engine: server: remove recalculating viewpoint for PVS hack, as it causes issues with inconsistency between real and "restored" view positions 2024-05-29 05:41:47 +03:00
Alibek Omarov
9150b770e4 engine: common: mod_bmodel: add function Mod_DecompressVisTo that will copy fat vis data into the provided buffer 2024-05-29 05:41:47 +03:00
Alibek Omarov
2ad6511c31 public: add Q_memor routine that binary OR's data from src to dst
Supposed to be compiled with optimizations enabled.
2024-05-29 05:41:33 +03:00
Alibek Omarov
0848f28d83 waf: upgrade to latest master 2024-05-26 19:32:14 +03:00
52 changed files with 720 additions and 447 deletions

View File

@@ -1,15 +1,3 @@
task:
name: freebsd-13-amd64
freebsd_instance:
image_family: freebsd-13-2
setup_script:
- pkg update
- pkg install -y pkgconf git sdl2 python fontconfig opus
- git submodule update --init --recursive
test_script:
- ./scripts/cirrus/build_freebsd.sh dedicated
- ./scripts/cirrus/build_freebsd.sh full
task:
name: freebsd-14-amd64
freebsd_instance:

View File

@@ -1,25 +0,0 @@
/*
boneinfo.h - structure that send delta-compressed bones across network
Copyright (C) 2018 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef BONEINFO_H
#define BONEINFO_H
typedef struct
{
vec3_t angles;
vec3_t origin;
} boneinfo_t;
#endif//BONEINFO_H

View File

@@ -83,12 +83,15 @@ typedef uint64_t longtime_t;
#define NONNULL __attribute__(( nonnull ))
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
#define RENAME_SYMBOL( x ) asm( x )
#else
#if defined( _MSC_VER )
#define EXPORT __declspec( dllexport )
#define NO_ASAN __declspec( no_sanitize_address )
#else
#define EXPORT
#define NO_ASAN
#endif
#define GAME_EXPORT
#define NORETURN
@@ -98,18 +101,17 @@ typedef uint64_t longtime_t;
#define RENAME_SYMBOL( x )
#endif
#if ( __GNUC__ >= 3 )
#if __GNUC__ >= 3
#define unlikely( x ) __builtin_expect( x, 0 )
#define likely( x ) __builtin_expect( x, 1 )
#elif defined( __has_builtin )
#if __has_builtin( __builtin_expect )
#define unlikely( x ) __builtin_expect( x, 0 )
#define likely( x ) __builtin_expect( x, 1 )
#else
#define unlikely( x ) ( x )
#define likely( x ) ( x )
#if __has_builtin( __builtin_expect ) // this must be after defined() check
#define unlikely( x ) __builtin_expect( x, 0 )
#define likely( x ) __builtin_expect( x, 1 )
#endif
#else
#endif
#if !defined( unlikely ) || !defined( likely )
#define unlikely( x ) ( x )
#define likely( x ) ( x )
#endif
@@ -128,6 +130,14 @@ typedef uint64_t longtime_t;
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
#endif
#if !defined( __cplusplus ) && __STDC_VERSION__ >= 199101L // not C++ and C99 or newer
#define XASH_RESTRICT restrict
#elif _MSC_VER || __GNUC__ || __clang__ // compiler-specific extensions
#define XASH_RESTRICT __restrict
#else
#define XASH_RESTRICT // nothing
#endif
#ifdef XASH_BIG_ENDIAN
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))
#define LittleLongSW(x) (x = LittleLong(x) )

View File

@@ -70,16 +70,17 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
return true;
}
if( cl.downloadUrl[0] )
host.downloadcount++;
if( cl.http_download )
{
HTTP_AddDownload( filepath, pResource->nDownloadSize, true );
host.downloadcount++;
return false;
}
MSG_BeginClientCmd( msg, clc_stringcmd );
MSG_WriteStringf( msg, "dlfile %s", filepath );
host.downloadcount++;
else
{
MSG_BeginClientCmd( msg, clc_stringcmd );
MSG_WriteStringf( msg, "dlfile %s", filepath );
}
return false;
}

View File

@@ -1097,6 +1097,20 @@ static void GAME_EXPORT pfnCon_DefaultColor( int r, int g, int b )
Con_DefaultColor( r, g, b, true );
}
static void GAME_EXPORT pfnSetCursor( void *hCursor )
{
uintptr_t cursor;
if( !gameui.use_extended_api )
return; // ignore original Xash menus
cursor = (uintptr_t)hCursor;
if( cursor < dc_user || cursor > dc_last )
return;
Platform_SetCursorType( cursor );
}
// engine callbacks
static ui_enginefuncs_t gEngfuncs =
{
@@ -1176,7 +1190,7 @@ static ui_enginefuncs_t gEngfuncs =
pfnHostEndGame,
COM_RandomFloat,
COM_RandomLong,
IN_SetCursor,
pfnSetCursor,
pfnIsMapValid,
GL_ProcessTexture,
COM_CompareFileTime,
@@ -1286,7 +1300,7 @@ qboolean UI_LoadProgs( void )
}
gameui.use_text_api = false;
gameui.use_extended_api = false;
// make local copy of engfuncs to prevent overwrite it with user dll
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
@@ -1313,7 +1327,7 @@ qboolean UI_LoadProgs( void )
if( GetExtAPI( MENU_EXTENDED_API_VERSION, &gameui.dllFuncs2, &gpExtendedfuncs ) )
{
Con_Reportf( "UI_LoadProgs: extended Menu API initialized\n" );
gameui.use_text_api = true;
gameui.use_extended_api = true;
}
}
else // otherwise, fallback to old and deprecated extensions
@@ -1325,7 +1339,7 @@ qboolean UI_LoadProgs( void )
if( GiveTextApi( &gpExtendedfuncs ) ) // they are binary compatible, so we can just pass extended funcs API to menu
{
Con_Reportf( "UI_LoadProgs: extended text API initialized\n" );
gameui.use_text_api = true;
gameui.use_extended_api = true;
}
}

View File

@@ -587,21 +587,38 @@ CL_CreateCmd
*/
static void CL_CreateCmd( void )
{
usercmd_t nullcmd, *cmd;
runcmd_t *pcmd;
vec3_t angles;
qboolean active;
int input_override;
int i, ms;
usercmd_t nullcmd, *cmd;
runcmd_t *pcmd;
qboolean active;
double accurate_ms;
vec3_t angles;
int input_override;
int i, ms;
if( cls.state < ca_connected || cls.state == ca_cinematic )
return;
// store viewangles in case it's will be freeze
VectorCopy( cl.viewangles, angles );
ms = bound( 1, host.frametime * 1000, 255 );
input_override = 0;
// fix rounding error and framerate depending player move
accurate_ms = host.frametime * 1000;
ms = (int)accurate_ms;
cl.frametime_remainder += accurate_ms - ms; // accumulate rounding error each frame
// add a ms if error accumulates enough
if( cl.frametime_remainder >= 1.0 )
{
int ms2 = (int)cl.frametime_remainder;
ms += ms2;
cl.frametime_remainder -= ms2;
}
// ms can't be negative, rely on error accumulation only if FPS > 1000
ms = Q_min( ms, 255 );
CL_SetSolidEntities();
CL_PushPMStates();
CL_SetSolidPlayers( cl.playernum );
@@ -1618,9 +1635,17 @@ static size_t NONNULL CL_BuildMasterServerScanRequest( char *buf, size_t size, u
#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
// let master know about client version
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining );
Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining );
Info_SetValueForKey( info, "commit", Q_buildcommit(), remaining );
Info_SetValueForKey( info, "branch", Q_buildbranch(), remaining );
Info_SetValueForKey( info, "os", Q_buildos(), remaining );
Info_SetValueForKey( info, "arch", Q_buildarch(), remaining );
Q_snprintf( temp, sizeof( temp ), "%d", Q_buildnum() );
Info_SetValueForKey( info, "buildnum", temp, remaining );
Q_snprintf( temp, sizeof( temp ), "%x", *key );
Info_SetValueForKey( info, "key", temp, remaining );
@@ -2510,11 +2535,6 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
return;
}
pfilename = filename;
if( !Q_strnicmp( filename, DEFAULT_SOUNDPATH, sound_len ))
pfilename += sound_len;
for( p = cl.resourcesneeded.pNext; p != &cl.resourcesneeded; p = p->pNext )
{
if( !Q_strnicmp( filename, "!MD5", 4 ))
@@ -2524,18 +2544,20 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
if( !memcmp( p->rgucMD5_hash, rgucMD5_hash, 16 ))
break;
}
else if( p->type == t_sound )
{
const char *pfilename = filename;
if( !Q_strnicmp( filename, DEFAULT_SOUNDPATH, sound_len ))
pfilename += sound_len;
if( !Q_stricmp( p->szFileName, pfilename ))
break;
}
else
{
if( p->type == t_generic )
{
if( !Q_stricmp( p->szFileName, filename ))
if( !Q_stricmp( p->szFileName, filename ))
break;
}
else
{
if( !Q_stricmp( p->szFileName, pfilename ))
break;
}
}
}
@@ -2600,7 +2622,7 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
if( cls.netchan.tempbuffer )
{
Con_Printf( "Received a decal %s, but didn't find it in resources needed list!\n", pfilename );
Con_Printf( "Received a decal %s, but didn't find it in resources needed list!\n", filename );
Mem_Free( cls.netchan.tempbuffer );
}
@@ -2693,10 +2715,32 @@ static void CL_Physinfo_f( void )
Con_Printf( "Total %i symbols\n", Q_strlen( cls.physinfo ));
}
static qboolean CL_ShouldRescanFilesystem( void )
{
resource_t *res;
for( res = cl.resourcesonhand.pNext; res && res != &cl.resourcesonhand; res = res->pNext )
{
if( res->type == t_generic )
{
const char *ext = COM_FileExtension( res->szFileName );
// TODO: query supported archives format from fs_stdio
// TODO: query if was already opened
if( !Q_stricmp( ext, "wad" ) || !Q_stricmp( ext, "pk3" ) || !Q_stricmp( ext, "pak" ))
return true;
}
}
return false;
}
qboolean CL_PrecacheResources( void )
{
resource_t *pRes;
// if we downloaded new WAD files or any other archives they must be added to searchpath
if( CL_ShouldRescanFilesystem( ))
g_fsapi.Rescan();
// NOTE: world need to be loaded as first model
for( pRes = cl.resourcesonhand.pNext; pRes && pRes != &cl.resourcesonhand; pRes = pRes->pNext )
{

View File

@@ -458,6 +458,7 @@ void CL_BatchResourceRequest( qboolean initialize )
byte data[MAX_INIT_MSG];
resource_t *p, *n;
sizebuf_t msg;
qboolean done_downloading = true;
MSG_Init( &msg, "Resource Batch", data, sizeof( data ));
@@ -487,7 +488,10 @@ void CL_BatchResourceRequest( qboolean initialize )
case t_model:
case t_eventscript:
if( !CL_CheckFile( &msg, p ))
{
done_downloading = false;
break;
}
CL_MoveToOnHandList( p );
break;
case t_skin:
@@ -501,6 +505,7 @@ void CL_BatchResourceRequest( qboolean initialize )
MSG_BeginClientCmd( &msg, clc_stringcmd );
MSG_WriteStringf( &msg, "dlfile !MD5%s", MD5_Print( p->rgucMD5_hash ));;
SetBits( p->ucFlags, RES_REQUESTED );
done_downloading = false;
}
break;
}
@@ -525,11 +530,7 @@ void CL_BatchResourceRequest( qboolean initialize )
if( cls.state != ca_disconnected )
{
if( !cl.downloadUrl[0] && !MSG_GetNumBytesWritten( &msg ) && CL_PrecacheResources( ))
{
CL_RegisterResources( &msg );
}
if( cl.downloadUrl[0] && host.downloadcount == 0 && CL_PrecacheResources( ) )
if( done_downloading && CL_PrecacheResources( ))
{
CL_RegisterResources( &msg );
}
@@ -1840,13 +1841,10 @@ void CL_ParseResLocation( sizebuf_t *msg )
return;
}
while( ( data = COM_ParseFile( data, token, sizeof( token ) ) ) )
while(( data = COM_ParseFile( data, token, sizeof( token ))))
{
Con_Reportf( "Adding %s as download location\n", token );
if( !cl.downloadUrl[0] )
Q_strncpy( cl.downloadUrl, token, sizeof( token ) );
cl.http_download = true;
HTTP_AddCustomServer( token );
}
}

View File

@@ -844,7 +844,7 @@ static void CL_QuakeExecStuff( void )
while( 1 )
{
// skip whitespace up to a /n
while( *text && ((byte)*text) <= ' ' && *text != '\r' && *text != '\n' )
while( *text && ((byte)*text ) <= ' ' && *text != '\r' && *text != '\n' )
text++;
if( *text == '\n' || *text == '\r' )

View File

@@ -20,7 +20,7 @@ GNU General Public License for more details.
int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis )
{
return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis );
return Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis, false );
}
lightstyle_t *CL_GetLightStyle( int number )

View File

@@ -229,7 +229,7 @@ typedef struct
char serverinfo[MAX_SERVERINFO_STRING];
player_info_t players[MAX_CLIENTS]; // collected info about all other players include himself
double lastresourcecheck;
string downloadUrl;
qboolean http_download;
event_state_t events;
// predicting stuff but not only...
@@ -276,6 +276,8 @@ typedef struct
model_t *worldmodel; // pointer to world
int lostpackets; // count lost packets and show dialog in menu
double frametime_remainder;
} client_t;
/*
@@ -518,7 +520,7 @@ typedef struct
int logo_yres;
float logo_length;
qboolean use_text_api;
qboolean use_extended_api;
} gameui_static_t;
typedef struct
@@ -630,6 +632,9 @@ typedef struct
int extensions;
netadr_t serveradr;
// do we accept utf8 as input
qboolean accept_utf8;
} client_static_t;
#ifdef __cplusplus

View File

@@ -35,7 +35,6 @@ static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in m
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
static int g_codepage = 0;
static qboolean g_utf8 = false;
static qboolean g_messagemode_privileged = true;
@@ -635,10 +634,13 @@ int Con_UtfProcessCharForce( int in )
int GAME_EXPORT Con_UtfProcessChar( int in )
{
if( !g_utf8 )
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return in;
// otherwise, decode it and convert to selected codepage
return Con_UtfProcessCharForce( in );
}
/*
=================
Con_UtfMoveLeft
@@ -652,7 +654,7 @@ int Con_UtfMoveLeft( char *str, int pos )
int k = 0;
int i;
if( !g_utf8 )
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return pos - 1;
if( pos == 1 )
@@ -679,7 +681,7 @@ int Con_UtfMoveRight( char *str, int pos, int length )
utfstate_t state = { 0 };
int i;
if( !g_utf8 )
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return pos + 1;
for( i = pos; i <= length; i++ )
@@ -2097,7 +2099,7 @@ void Con_RunConsole( void )
g_codepage = 1252;
}
g_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
cls.accept_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
Con_InvalidateFonts();
Con_LoadConchars();
ClearBits( con_charset.flags, FCVAR_CHANGED );

View File

@@ -17,6 +17,7 @@ GNU General Public License for more details.
#include "input.h"
#include "client.h"
#include "vgui_draw.h"
#include "cursor_type.h"
#if XASH_SDL
#include <SDL.h>
@@ -123,11 +124,6 @@ static void IN_StartupMouse( void )
in_mouseinitialized = true;
}
void GAME_EXPORT IN_SetCursor( void *hCursor )
{
// stub
}
/*
===========
IN_MouseSavePos

View File

@@ -40,7 +40,6 @@ void IN_DeactivateMouse( void );
void IN_MouseSavePos( void );
void IN_MouseRestorePos( void );
void IN_ToggleClientMouse( int newstate, int oldstate );
void IN_SetCursor( void *hCursor );
uint IN_CollectInputDevices( void );
void IN_LockInputDevices( qboolean lock );

View File

@@ -553,7 +553,7 @@ static void Key_AddKeyCommands( int key, const char *kb, qboolean down )
}
buttonPtr = button;
while(( kb[i] <= ' ' || kb[i] == ';' ) && kb[i] != 0 )
while((((byte)kb[i]) <= ' ' || kb[i] == ';' ) && kb[i] != 0 )
i++;
}
@@ -749,10 +749,10 @@ void GAME_EXPORT Key_Event( int key, int down )
if( cls.key_dest == key_menu )
{
// only non printable keys passed
if( !gameui.use_text_api )
if( !gameui.use_extended_api )
Key_EnableTextInput( true, false );
//pass printable chars for old menus
if( !gameui.use_text_api && !host.textmode && down && ( key >= 32 ) && ( key <= 'z' ) )
if( !gameui.use_extended_api && !host.textmode && down && ( key >= 32 ) && ( key <= 'z' ) )
{
if( Key_IsDown( K_SHIFT ) )
{
@@ -1055,15 +1055,16 @@ static qboolean OSK_KeyEvent( int key, int down )
break;
}
ch = Con_UtfProcessChar((byte)osk.curbutton.val );
ch = (byte)osk.curbutton.val;
// do not pass UTF-8 sequence into the engine, convert it here
if( !cls.accept_utf8 )
ch = Con_UtfProcessCharForce( ch );
if( !ch )
break;
Con_CharEvent( ch );
if( cls.key_dest == key_menu )
UI_CharEvent ( ch );
CL_CharEvent( ch );
break;
}
}
@@ -1118,7 +1119,6 @@ static void OSK_EnableTextInput( qboolean enable, qboolean force )
{
osk.curlayout = 0;
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
}
}

View File

@@ -685,6 +685,9 @@ void Mod_CreatePolygonsForHull( int hullnum )
if( hullnum < 1 || hullnum > 3 )
return;
if( !world.num_hull_models )
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
Con_Printf( "generating polygons for hull %u...\n", hullnum );
start = Sys_DoubleTime();

View File

@@ -154,7 +154,8 @@ static const sx_preset_t rgsxpre_hlalpha052[] =
static const sx_preset_t *ptable = rgsxpre;
// cvars
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing" );
static CVAR_DEFINE_AUTO( dsp_off, "0", FCVAR_ARCHIVE, "disable DSP processing (deprecated)" );
static CVAR_DEFINE_AUTO( room_off, "0", FCVAR_ARCHIVE, "disable DSP processing (GoldSrc compatible cvar)" );
static CVAR_DEFINE_AUTO( dsp_coeff_table, "0", FCVAR_ARCHIVE, "select DSP coefficient table: 0 for release or 1 for alpha 0.52" );
static CVAR_DEFINE_AUTO( room_type, "0", 0, "current room type preset" );
@@ -232,6 +233,7 @@ void SX_Init( void )
sxmod2cur = sxmod2 = 450 * ( idsp_dma_speed / SOUND_11k );
Cvar_RegisterVariable( &dsp_off );
Cvar_RegisterVariable( &room_off );
Cvar_RegisterVariable( &dsp_coeff_table );
Cvar_RegisterVariable( &roomwater_type );
@@ -809,7 +811,7 @@ DSP_Process
*/
void DSP_Process( portable_samplepair_t *pbfront, int sampleCount )
{
if( dsp_off.value || !sampleCount )
if( dsp_off.value || room_off.value || !sampleCount )
return;
// preset is already installed by CheckNewDspPresets
@@ -843,7 +845,7 @@ CheckNewDspPresets
*/
void CheckNewDspPresets( void )
{
if( dsp_off.value != 0.0f )
if( dsp_off.value || room_off.value )
return;
if( FBitSet( dsp_coeff_table.flags, FCVAR_CHANGED ))

View File

@@ -640,7 +640,7 @@ void Cmd_TokenizeString( const char *text )
while( 1 )
{
// skip whitespace up to a /n
while( *text && *text <= ' ' && *text != '\r' && *text != '\n' )
while( *text && ((byte)*text ) <= ' ' && *text != '\r' && *text != '\n' )
text++;
if( *text == '\n' || *text == '\r' )

View File

@@ -25,16 +25,19 @@ GNU General Public License for more details.
static const char *file_exts[] =
{
"cfg",
"lst",
"exe",
"vbs",
"com",
"bat",
"dll",
"ini",
"log",
"sys",
// ban text files that don't make sense as resource
"cfg", "lst", "ini", "log",
// ban Windows code
"exe", "vbs", "com", "bat",
"dll", "sys", "ps1",
// ban common unix code
// NOTE: in unix anything can be executed as long it has access flag
"so", "sh", "dylib",
// ban mobile archives
"apk", "ipa",
};
#ifdef _DEBUG
@@ -900,7 +903,10 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
if( !COM_CheckString( filename ))
return false;
if( !Q_strncmp( filename, "!MD5", 4 ))
ext = COM_FileExtension( lwrfilename );
// only allow extensionless files that start with !MD5
if( !Q_strncmp( filename, "!MD5", 4 ) && ext[0] == 0 )
return true;
Q_strnlwr( filename, lwrfilename, sizeof( lwrfilename ));
@@ -923,8 +929,6 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
if( Q_strlen( first ) != 4 )
return false;
ext = COM_FileExtension( lwrfilename );
for( i = 0; i < ARRAYSIZE( file_exts ); i++ )
{
if( !Q_stricmp( ext, file_exts[i] ))

View File

@@ -129,6 +129,22 @@ static void Sys_StackTrace( PEXCEPTION_POINTERS pInfo )
stackframe.AddrBStore.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.IntSp;
stackframe.AddrStack.Mode = AddrModeFlat;
#elif _M_ARM
image = IMAGE_FILE_MACHINE_ARMNT;
stackframe.AddrPC.Offset = context.Pc;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.R11;
stackframe.AddrFrame.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.Sp;
stackframe.AddrStack.Mode = AddrModeFlat;
#elif _M_ARM64
image = IMAGE_FILE_MACHINE_ARM64;
stackframe.AddrPC.Offset = context.Pc;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.Fp;
stackframe.AddrFrame.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.Sp;
stackframe.AddrStack.Mode = AddrModeFlat;
#elif
#error
#endif

View File

@@ -24,6 +24,9 @@ GNU General Public License for more details.
#include "client.h"
#include "server.h" // LUMP_ error codes
#include "ref_common.h"
#if defined( HAVE_OPENMP )
#include <omp.h>
#endif // HAVE_OPENMP
#define MIPTEX_CUSTOM_PALETTE_SIZE_BYTES ( sizeof( int16_t ) + 768 )
@@ -578,6 +581,42 @@ void Mod_PrintWorldStats_f( void )
===============================================================================
*/
/*
===================
Mod_DecompressPVS
TODO: replace all Mod_DecompressPVS calls by this
===================
*/
static void Mod_DecompressPVSTo( byte *const out, const byte *in, size_t visbytes )
{
byte *dst = out;
if( !in ) // no visinfo, make all visible
{
memset( out, 0xFF, visbytes );
return;
}
while( dst < out + visbytes )
{
if( *in ) // uncompressed
{
*dst++ = *in++;
}
else // zero repeated `c` times
{
size_t c = in[1];
if( c > out + visbytes - dst )
c = out + visbytes - dst;
memset( dst, 0, c );
in += 2;
dst += c;
}
}
}
/*
===================
Mod_DecompressPVS
@@ -585,41 +624,36 @@ Mod_DecompressPVS
*/
static byte *Mod_DecompressPVS( const byte *in, int visbytes )
{
byte *out;
int c;
Mod_DecompressPVSTo( g_visdata, in, visbytes );
return g_visdata;
}
out = g_visdata;
static size_t Mod_CompressPVS( byte *const out, const byte *in, size_t inbytes )
{
size_t i;
byte *dst = out;
if( !in )
for( i = 0; i < inbytes; i++ )
{
// no vis info, so make all visible
while( visbytes )
size_t j = i + 1, rep = 1;
*dst++ = in[i];
// only compress zeros
if( in[i] )
continue;
for( ; j < inbytes && rep != 255; j++, rep++ )
{
*out++ = 0xff;
visbytes--;
if( in[j] )
break;
}
return g_visdata;
*dst++ = rep;
i = j - 1;
}
do
{
if( *in )
{
*out++ = *in++;
continue;
}
c = in[1];
in += 2;
while( c )
{
*out++ = 0;
c--;
}
} while( out - g_visdata < visbytes );
return g_visdata;
return dst - out;
}
/*
@@ -653,22 +687,11 @@ NOTE: can return NULL
*/
byte *Mod_GetPVSForPoint( const vec3_t p )
{
mnode_t *node;
mleaf_t *leaf = NULL;
mleaf_t *leaf;
ASSERT( worldmodel != NULL );
node = worldmodel->nodes;
while( 1 )
{
if( node->contents < 0 )
{
leaf = (mleaf_t *)node;
break; // we found a leaf
}
node = node->children[PlaneDiff( p, node->plane ) <= 0];
}
leaf = Mod_PointInLeaf( p, worldmodel->nodes );
if( leaf && leaf->cluster >= 0 )
return Mod_DecompressPVS( leaf->compressed_vis, world.visbytes );
@@ -681,7 +704,7 @@ Mod_FatPVS_RecursiveBSPNode
==================
*/
static void Mod_FatPVS_RecursiveBSPNode( const vec3_t org, float radius, byte *visbuffer, int visbytes, mnode_t *node )
static void Mod_FatPVS_RecursiveBSPNode( const vec3_t org, float radius, byte *visbuffer, int visbytes, mnode_t *node, qboolean phs )
{
int i;
@@ -696,7 +719,7 @@ static void Mod_FatPVS_RecursiveBSPNode( const vec3_t org, float radius, byte *v
else
{
// go down both sides
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, visbytes, node->children[0] );
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, visbytes, node->children[0], phs );
node = node->children[1];
}
}
@@ -704,10 +727,19 @@ static void Mod_FatPVS_RecursiveBSPNode( const vec3_t org, float radius, byte *v
// if this leaf is in a cluster, accumulate the vis bits
if(((mleaf_t *)node)->cluster >= 0 )
{
byte *vis = Mod_DecompressPVS( ((mleaf_t *)node)->compressed_vis, world.visbytes );
byte *vis;
for( i = 0; i < visbytes; i++ )
visbuffer[i] |= vis[i];
if( phs )
{
int i = ((mleaf_t *)node)->cluster + 1;
vis = Mod_DecompressPVS( &world.compressed_phs[world.phsofs[i]], world.visbytes );
}
else
{
vis = Mod_DecompressPVS( ((mleaf_t *)node)->compressed_vis, world.visbytes );
}
Q_memor( visbuffer, vis, visbytes );
}
}
@@ -719,7 +751,7 @@ Calculates a PVS that is the inclusive or of all leafs
within radius pixels of the given point.
==================
*/
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis )
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis, qboolean phs )
{
int bytes = world.visbytes;
mleaf_t *leaf = NULL;
@@ -736,9 +768,17 @@ int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, q
return bytes;
}
// requested PHS but we don't have PHS for some reason
// enable full visibility
if( phs && !( world.compressed_phs && world.phsofs ))
{
memset( visbuffer, 0xFF, bytes );
return bytes;
}
if( !merge ) memset( visbuffer, 0x00, bytes );
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, bytes, worldmodel->nodes );
Mod_FatPVS_RecursiveBSPNode( org, radius, visbuffer, bytes, worldmodel->nodes, phs );
return bytes;
}
@@ -1835,7 +1875,7 @@ static void Mod_LoadEntities( model_t *mod, dbspmodel_t *bmod )
COM_FixSlashes( pszWadFile );
COM_FileBase( pszWadFile, token, sizeof( token ));
// make sure what wad is really exist
// make sure that wad is really exist
if( FS_FileExists( va( "%s.wad", token ), false ))
{
int num = bmod->wadlist.count++;
@@ -2028,18 +2068,16 @@ static qboolean Mod_LooksLikeWaterTexture( const char *name )
static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureIndex )
{
#if !XASH_DEDICATED
texture_t *texture = NULL;
mip_t *mipTex = NULL;
qboolean usesCustomPalette = false;
uint32_t txFlags = 0;
// Don't load texture data on dedicated server, as there is no renderer.
// don't load texture data on dedicated server, as there is no renderer.
// but count the wadusage for automatic precache
//
// FIXME: for ENGINE_IMPROVED_LINETRACE we need to load textures on server too
// but there is no facility for this yet
if( Host_IsDedicated( ))
return;
texture = mod->textures[textureIndex];
mipTex = Mod_GetMipTexForTexture( bmod, textureIndex );
@@ -2055,10 +2093,15 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
// check for multi-layered sky texture (quake1 specific)
if( bmod->isworld && Q_strncmp( mipTex->name, "sky", 3 ) == 0 && ( mipTex->width / mipTex->height ) == 2 )
{
ref.dllFuncs.R_InitSkyClouds( mipTex, texture, usesCustomPalette ); // load quake sky
#if !XASH_DEDICATED
if( !Host_IsDedicated( ))
{
ref.dllFuncs.R_InitSkyClouds( mipTex, texture, usesCustomPalette ); // load quake sky
if( R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) && R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ))
SetBits( world.flags, FWORLD_SKYSPHERE );
if( R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) && R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ))
SetBits( world.flags, FWORLD_SKYSPHERE );
}
#endif // !XASH_DEDICATED
// No texture to load in this case, so just exit.
return;
@@ -2076,11 +2119,18 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
if( wadIndex >= 0 )
{
texture->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, txFlags );
#if !XASH_DEDICATED
if( !Host_IsDedicated( ))
texture->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, txFlags );
#endif // !XASH_DEDICATED
bmod->wadlist.wadusage[wadIndex]++;
}
}
#if !XASH_DEDICATED
if( Host_IsDedicated( ))
return;
// WAD failed, so use internal texture (if present)
if( mipTex->offsets[0] > 0 && texture->gl_texturenum == 0 )
{
@@ -2709,6 +2759,153 @@ static void Mod_LoadLeafs( model_t *mod, dbspmodel_t *bmod )
SetBits( world.flags, FWORLD_WATERALPHA );
}
/*
===========
Mod_CalcPHS
To be called while loading world for multiplayer game server
===========
*/
static void Mod_CalcPHS( model_t *mod )
{
const qboolean vis_stats = host_developer.value >= DEV_EXTENDED;
const size_t rowbytes = ALIGN( world.visbytes, 4 ); // force align rows by 32-bit boundary
const size_t count = mod->numleafs + 1; // same as mod->submodels[0].visleafs + 1
double t1;
double t2;
size_t total_compressed_size = 0;
size_t hcount = 0;
size_t vcount = 0;
int i;
byte *uncompressed_pvs;
byte *uncompressed_phs;
if( !mod->visdata )
return;
#if defined( HAVE_OPENMP )
Con_Reportf( "Building PHS in %d threads...\n", omp_get_max_threads( ));
#else
Con_Reportf( "Building PHS...\n" );
#endif
uncompressed_pvs = Mem_Calloc( mod->mempool, rowbytes * count * 2 );
uncompressed_phs = &uncompressed_pvs[rowbytes * count];
world.phsofs = Mem_Calloc( mod->mempool, sizeof( size_t ) * count );
world.compressed_phs = NULL;
t1 = Platform_DoubleTime();
#pragma omp parallel
{
// uncompress pvs first
#pragma omp for schedule( static, 256 ) // there might be thousands of leafs, split by 256
for( i = 0; i < count; i++ )
Mod_DecompressPVSTo( &uncompressed_pvs[rowbytes * i], mod->leafs[i].compressed_vis, world.visbytes );
// now create phs
#pragma omp for schedule( static, 256 ) reduction( + : vcount, hcount )
for( i = 0; i < count; i++ )
{
const byte *scan = &uncompressed_pvs[rowbytes * i];
byte *dst = &uncompressed_phs[rowbytes * i]; // rowbytes, not rowwords!
size_t j;
memcpy( dst, scan, rowbytes );
for( j = 0; j < rowbytes; j++ )
{
size_t k;
uint bitbyte = scan[j];
if( bitbyte == 0 )
continue;
for( k = 0; k < 8; k++ )
{
size_t index;
if( !FBitSet( bitbyte, BIT( k )))
continue;
// OR this pvs row into the phs
// +1 because pvs is 1 based
index = (( j * 8 ) + k + 1 );
if( index >= count )
continue;
Q_memor( dst, &uncompressed_pvs[rowbytes * index], rowbytes );
}
}
if( vis_stats && i != 0 )
{
size_t j;
for( j = 0; j < count; j++ )
{
if( CHECKVISBIT( scan, j ))
vcount++;
if( CHECKVISBIT( dst, j ))
hcount++;
}
}
}
}
// since I can't predict at which spot compressed array
// should be put, this loop is single threaded
for( i = 0; i < count; i++ )
{
const byte *src = &uncompressed_phs[rowbytes * i];
byte temp_compressed_row[(MAX_MAP_LEAFS+1)/4]; // compression for this row might be ineffective
size_t compressed_size;
compressed_size = Mod_CompressPVS( temp_compressed_row, src, rowbytes );
world.compressed_phs = Mem_Realloc( mod->mempool, world.compressed_phs, total_compressed_size + compressed_size );
memcpy( &world.compressed_phs[total_compressed_size], temp_compressed_row, compressed_size );
world.phsofs[i] = total_compressed_size;
total_compressed_size += compressed_size;
}
t2 = Platform_DoubleTime();
if( vis_stats )
Con_Reportf( "Average leaves visible / audible / total: %i / %i / %i\n", vcount / count, hcount / count, count );
Con_Reportf( "Uncompressed PHS size: %s\n", Q_memprint( rowbytes * count ));
Con_Reportf( "Compressed PHS size: %s\n", Q_memprint( total_compressed_size + sizeof( *world.phsofs ) * count ));
Con_Reportf( "PHS building time: %.2f ms\n", ( t2 - t1 ) * 1000.0f );
// TODO: rewrite this into a unit test
// NOTE: how to get GoldSrc fat PHS and PVS data
// start a multiplayer server with some op4_bootcamp (for example)
// attach to process with GDB:
// (gdb) p gPAS[0]
// $0 = (byte *) ...
// (gdb) p gPAS[gPVSRowBytes * (cl.worldmodel->numleafs + 1)]
// $1 = (byte *) ...
// (gdb) dump binary memory op4_bootcamp_gs.phs $0 $1
// (gdb) p gPVS[0]
// $2 = (byte *) ...
// (gdb) p gPVS[gPVSRowBytes * (cl.worldmodel->numleafs + 1)]
// $3 = (byte *) ...
// (gdb) dump binary memory op4_bootcamp_gs.pvs $0 $1
//
// NOTE: as of writing, uncompressed PVS and PHS data do match! hooray!
//
// FS_WriteFile( "op4_bootcamp.pvs", uncompressed_pvs, rowbytes * count );
// FS_WriteFile( "op4_bootcamp.phs", uncompressed_phs, rowbytes * count );
// release uncompressed data
Mem_Free( uncompressed_pvs );
// TODO: cache the PHS somewhere, it might take a long time on giant maps
}
/*
=================
Mod_LoadClipnodes
@@ -2906,6 +3103,7 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
char wadvalue[2048];
size_t len = 0;
int i, ret, flags = 0;
qboolean wadlist_warn = false;
// always reset the intermediate struct
memset( bmod, 0, sizeof( dbspmodel_t ));
@@ -3000,23 +3198,37 @@ static qboolean Mod_LoadBmodelLumps( model_t *mod, const byte *mod_base, qboolea
{
world.version = bmod->version;
#if !XASH_DEDICATED
Mod_InitDebugHulls( mod ); // FIXME: build hulls for separate bmodels (shells, medkits etc)
world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer
world.shadowdata = bmod->shadowdata_out; // occlusion data pointer
#endif // XASH_DEDICATED
if( SV_Active() && svs.maxclients > 1 )
Mod_CalcPHS( mod );
}
for( i = 0; i < bmod->wadlist.count; i++ )
{
string wadname;
if( !bmod->wadlist.wadusage[i] )
continue;
ret = Q_snprintf( &wadvalue[len], sizeof( wadvalue ), "%s.wad; ", bmod->wadlist.wadnames[i] );
if( ret == -1 )
Q_snprintf( wadname, sizeof( wadname ), "%s.wad", bmod->wadlist.wadnames[i] );
// a1ba: automatically precache used wad files so client will download it
if( SV_Active( ))
SV_GenericIndex( wadname );
if( !wadlist_warn )
{
Con_DPrintf( S_WARN "Too many wad files for output!\n" );
break;
ret = Q_snprintf( &wadvalue[len], sizeof( wadvalue ), "%s; ", wadname );
if( ret == -1 )
{
Con_DPrintf( S_WARN "Too many wad files for output!\n" );
wadlist_warn = true;
}
len += ret;
}
len += ret;
}
if( COM_CheckString( wadvalue ))

View File

@@ -33,7 +33,7 @@ GNU General Public License for more details.
#define REFPVS_RADIUS 2.0f // radius for rendering
#define FATPVS_RADIUS 8.0f // FatPVS use radius smaller than the FatPHS
#define FATPHS_RADIUS 16.0f
#define FATPHS_RADIUS 8.0f // see SV_AddToFatPAS in GoldSrc
#define WORLD_INDEX (1) // world index is always 1
@@ -115,6 +115,10 @@ typedef struct world_static_s
int max_recursion;
uint32_t version; // BSP version
// Potentially Hearable Set
byte *compressed_phs;
size_t *phsofs;
} world_static_t;
#ifndef REF_DLL
@@ -151,7 +155,7 @@ void Mod_FreeUnused( void );
void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded );
qboolean Mod_TestBmodelLumps( file_t *f, const char *name, const byte *mod_base, qboolean silent, dlump_t *entities );
qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf );
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis );
int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis, qboolean false );
qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits );
int Mod_CheckLump( const char *filename, const int lump, int *lumpsize );
int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize );

View File

@@ -780,7 +780,7 @@ extract texture filename from modelname
*/
const char *Mod_StudioTexName( const char *modname )
{
static char texname[MAX_QPATH];
static char texname[MAX_QPATH+1];
Q_strncpy( texname, modname, sizeof( texname ));
COM_StripExtension( texname );
@@ -841,6 +841,22 @@ static studiohdr_t *R_StudioLoadHeader( model_t *mod, const void *buffer )
return (studiohdr_t *)buffer;
}
static studiohdr_t *Mod_MaybeTruncateStudioTextureData( model_t *mod )
{
#if XASH_LOW_MEMORY
studiohdr_t *phdr = (studiohdr_t *)mod->cache.data;
mod->cache.data = Mem_Realloc( mod->mempool, mod->cache.data, phdr->texturedataindex );
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
phdr->length = phdr->texturedataindex; // update model size
return phdr;
#else
// NOTE: some mods potentially might require full studio model data
return (studiohdr_t *)mod->cache.data;
#endif
}
/*
=================
Mod_LoadStudioModel
@@ -860,73 +876,62 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
phdr = R_StudioLoadHeader( mod, buffer );
if( !phdr ) return; // bad model
if( !Host_IsDedicated() )
if( !Host_IsDedicated( ) && phdr->numtextures == 0 )
{
if( phdr->numtextures == 0 )
studiohdr_t *thdr;
void *buffer2;
buffer2 = FS_LoadFile( Mod_StudioTexName( mod->name ), NULL, false );
thdr = R_StudioLoadHeader( mod, buffer2 );
if( thdr != NULL )
{
studiohdr_t *thdr;
byte *in, *out;
void *buffer2 = NULL;
size_t size1, size2;
byte *in, *out;
size_t size1, size2;
buffer2 = FS_LoadFile( Mod_StudioTexName( mod->name ), NULL, false );
thdr = R_StudioLoadHeader( mod, buffer2 );
if( !thdr )
{
Con_Printf( S_WARN "Mod_LoadStudioModel: %s missing textures file\n", mod->name );
if( buffer2 ) Mem_Free( buffer2 );
}
else
{
#if !XASH_DEDICATED
ref.dllFuncs.Mod_StudioLoadTextures( mod, thdr );
// TODO: Mod_StudioLoadTextures will crash if passed a merged studio model!
ref.dllFuncs.Mod_StudioLoadTextures( mod, thdr );
#endif
// give space for textures and skinrefs
size1 = thdr->numtextures * sizeof( mstudiotexture_t );
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short );
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length + size1 + size2 );
memcpy( mod->cache.data, buffer, phdr->length ); // copy main mdl buffer
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
phdr->numskinfamilies = thdr->numskinfamilies;
phdr->numtextures = thdr->numtextures;
phdr->numskinref = thdr->numskinref;
phdr->textureindex = phdr->length;
phdr->skinindex = phdr->textureindex + size1;
in = (byte *)thdr + thdr->textureindex;
out = (byte *)phdr + phdr->textureindex;
memcpy( out, in, size1 + size2 ); // copy textures + skinrefs
phdr->length += size1 + size2;
Mem_Free( buffer2 ); // release T.mdl
}
}
else
{
// NOTE: don't modify source buffer because it's used for CRC computing
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length );
memcpy( mod->cache.data, buffer, phdr->length );
// give space for textures and skinrefs
size1 = thdr->numtextures * sizeof( mstudiotexture_t );
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short );
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length + size1 + size2 );
memcpy( mod->cache.data, buffer, phdr->length ); // copy main mdl buffer
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
#if !XASH_DEDICATED
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr );
#endif
phdr->numskinfamilies = thdr->numskinfamilies;
phdr->numtextures = thdr->numtextures;
phdr->numskinref = thdr->numskinref;
phdr->textureindex = phdr->length;
phdr->skinindex = phdr->textureindex + size1;
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
mod->cache.data = Mem_Realloc( mod->mempool, mod->cache.data, phdr->texturedataindex );
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
phdr->length = phdr->texturedataindex; // update model size
in = (byte *)thdr + thdr->textureindex;
out = (byte *)phdr + phdr->textureindex;
memcpy( out, in, size1 + size2 ); // copy textures + skinrefs
phdr->length += size1 + size2;
}
else Con_Printf( S_WARN "%s: %s missing textures file\n", __func__, mod->name );
if( buffer2 )
Mem_Free( buffer2 ); // release T.mdl
}
else
{
// just copy model into memory
// NOTE: don't modify source buffer because it's used for CRC computing
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length );
memcpy( mod->cache.data, buffer, phdr->length );
phdr = mod->cache.data;
#if !XASH_DEDICATED
if( !Host_IsDedicated( ))
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr );
#endif
}
// NOTE: we may not want to keep raw textures in memory. just cutoff model pointer above texture base
phdr = Mod_MaybeTruncateStudioTextureData( mod );
// setup bounding box
if( !VectorCompare( vec3_origin, phdr->bbmin ))
{

View File

@@ -114,6 +114,11 @@ void Mod_FreeModel( model_t *mod )
world.version = 0;
world.shadowdata = NULL;
world.deluxedata = NULL;
// data already freed by Mem_FreePool above
world.hull_models = NULL;
world.compressed_phs = NULL;
world.phsofs = NULL;
}
memset( mod, 0, sizeof( *mod ));

View File

@@ -174,7 +174,7 @@ void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove );
// Bit-write functions
void MSG_WriteOneBit( sizebuf_t *sb, int nValue );
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits );
NO_ASAN void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits );
void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits );
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned );
qboolean MSG_WriteBits( sizebuf_t *sb, const void *pData, int nBits );

View File

@@ -919,13 +919,20 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
int remaining;
int bufferid = 1;
fs_offset_t filesize = 0;
char compressedfilename[MAX_OSPATH];
int compressedFileTime;
int fileTime;
qboolean firstfragment = true;
qboolean bCompressed = false;
fragbufwaiting_t *wait, *p;
fragbuf_t *buf;
char compressedfilename[sizeof( buf->filename ) + 5];
// shouldn't be critical, but just in case
if( Q_strlen( filename ) > sizeof( buf->filename ) - 1 )
{
Con_Printf( S_WARN "Unable to transfer %s due to path length overflow\n", filename );
return 0;
}
if(( filesize = FS_FileSize( filename, false )) <= 0 )
{
@@ -937,8 +944,7 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
else chunksize = FRAGMENT_MAX_SIZE; // fallback
Q_strncpy( compressedfilename, filename, sizeof( compressedfilename ));
COM_ReplaceExtension( compressedfilename, ".ztmp", sizeof( compressedfilename ));
Q_snprintf( compressedfilename, sizeof( compressedfilename ), "%s.ztmp", filename );
compressedFileTime = FS_FileTime( compressedfilename, false );
fileTime = FS_FileTime( filename, false );
@@ -1521,10 +1527,9 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
if( pbuf->iscompressed )
{
char compressedfilename[MAX_OSPATH];
char compressedfilename[sizeof( pbuf->filename ) + 5];
Q_strncpy( compressedfilename, pbuf->filename, sizeof( compressedfilename ));
COM_ReplaceExtension( compressedfilename, ".ztmp", sizeof( compressedfilename ));
Q_snprintf( compressedfilename, sizeof( compressedfilename ), "%s.ztmp", pbuf->filename );
file = FS_Open( compressedfilename, "rb", false );
}
else file = FS_Open( pbuf->filename, "rb", false );

View File

@@ -2375,7 +2375,7 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
if( curfile->header_size >= sizeof( buf ))
{
Con_Reportf( S_ERROR "Header too big, the size is %s\n", curfile->header_size );
Con_Reportf( S_ERROR "Header too big, the size is %d\n", curfile->header_size );
HTTP_FreeFile( curfile, true );
return false;
}
@@ -2395,8 +2395,6 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
int cutheadersize = begin - curfile->buf + 4; // after that begin of data
char *content_length_line;
Con_Reportf( "HTTP: Got response!\n" );
if( !Q_strstr( curfile->buf, "200 OK" ))
{
*begin = 0; // cut string to print out response
@@ -2420,10 +2418,10 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
content_length_line += sizeof( "Content-Length: " ) - 1;
size = Q_atoi( content_length_line );
Con_Reportf( "HTTP: File size is %d\n", size );
Con_Reportf( "HTTP: Got 200 OK! File size is %d\n", size );
if( ( curfile->size != -1 ) && ( curfile->size != size )) // check size if specified, not used
Con_Reportf( S_WARN "Server reports wrong file size!\n" );
Con_Reportf( S_WARN "Server reports wrong file size for %s!\n", curfile->path );
curfile->size = size;
curfile->header_size = 0;
@@ -2535,7 +2533,7 @@ void HTTP_Run( void )
if( !curfile->file )
{
Con_Printf( S_ERROR "cannot open %s!\n", name );
Con_Printf( S_ERROR "HTTP: cannot open %s!\n", name );
HTTP_FreeFile( curfile, true );
break;
}

View File

@@ -87,7 +87,7 @@ int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavin
if( !mh || !sc ) return 0;
ret = mpg123_replace_reader_handle( mh, (void *)f_read, (void *)f_seek, NULL );
ret = mpg123_replace_reader_handle( mh, f_read, f_seek, NULL );
if( ret != MPG123_OK )
return 0;

View File

@@ -34,9 +34,15 @@ typedef struct
int playtime; // stream size in milliseconds
} wavinfo_t;
#ifdef _MSC_VER // a1ba: MSVC6 don't have ssize_t
typedef long mpg_ssize_t;
#else
typedef ssize_t mpg_ssize_t;
#endif
// custom stdio
typedef long (*pfread)( void *handle, void *buf, size_t count );
typedef long (*pfseek)( void *handle, long offset, int whence );
typedef mpg_ssize_t (*pfread)( void *handle, void *buf, size_t count );
typedef fs_offset_t (*pfseek)( void *handle, fs_offset_t offset, int whence );
extern void *create_decoder( int *error );
extern int feed_mpeg_header( void *mpg, const byte *data, long bufsize, long streamsize, wavinfo_t *sc );

View File

@@ -32,6 +32,7 @@ typedef struct mpg123_handle_s mpg123_handle_t;
#include <stdlib.h>
#include "fmt123.h"
#include STDINT_H
#include "xash3d_types.h"
#ifndef FALSE
#define FALSE 0
@@ -50,7 +51,7 @@ typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long ulong;
typedef unsigned int uint;
typedef long mpg_off_t;
typedef fs_offset_t mpg_off_t;
#ifdef _MSC_VER // a1ba: MSVC6 don't have ssize_t
typedef long mpg_ssize_t;

View File

@@ -853,11 +853,21 @@ int open_feed( mpg123_handle_t *fr )
return 0;
}
static mpg_ssize_t read_mpgtypes( int fd, void *buf, size_t count )
{
return read( fd, buf, count );
}
static mpg_off_t lseek_mpgtypes( int fd, mpg_off_t offset, int whence )
{
return lseek( fd, offset, whence );
}
static int default_init( mpg123_handle_t *fr )
{
fr->rdat.fdread = plain_read;
fr->rdat.read = fr->rdat.r_read != NULL ? fr->rdat.r_read : read;
fr->rdat.lseek = fr->rdat.r_lseek != NULL ? fr->rdat.r_lseek : lseek;
fr->rdat.read = fr->rdat.r_read != NULL ? fr->rdat.r_read : read_mpgtypes;
fr->rdat.lseek = fr->rdat.r_lseek != NULL ? fr->rdat.r_lseek : lseek_mpgtypes;
fr->rdat.filelen = get_fileinfo( fr );
fr->rdat.filepos = 0;

View File

@@ -291,14 +291,14 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, fs_offset_t filesi
return true;
}
/*
=================
FS_SeekEx
=================
*/
static fs_offset_t FS_SeekEx( file_t *file, fs_offset_t offset, int whence )
static fs_offset_t FS_SeekMpg( void *file, fs_offset_t offset, int whence )
{
return FS_Seek( file, offset, whence ) == -1 ? -1 : FS_Tell( file );
return g_fsapi.Seek((file_t *)file, offset, whence ) == -1 ? -1 : g_fsapi.Tell((file_t *)file );
}
static mpg_ssize_t FS_ReadMpg( void *file, void *buf, size_t count )
{
return g_fsapi.Read((file_t *)file, buf, count );
}
/*
@@ -334,7 +334,7 @@ stream_t *Stream_OpenMPG( const char *filename )
if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg ));
// trying to open stream and read header
if( !open_mpeg_stream( mpeg, file, (void*)FS_Read, (void*)FS_SeekEx, &sc ))
if( !open_mpeg_stream( mpeg, file, FS_ReadMpg, FS_SeekMpg, &sc ))
{
Con_DPrintf( S_ERROR "Stream_OpenMPG: failed to load (%s): %s\n", filename, get_error( mpeg ));
close_decoder( mpeg );

View File

@@ -20,63 +20,6 @@ GNU General Public License for more details.
#include "xash3d_mathlib.h"
#include "studio.h"
// just for debug
const char *et_name[] =
{
"normal",
"player",
"tempentity",
"beam",
"fragmented",
};
/*
===============================================================================
ENTITY LINKING
===============================================================================
*/
/*
===============
ClearLink
ClearLink is used for new headnodes
===============
*/
void ClearLink( link_t *l )
{
l->prev = l->next = l;
}
/*
===============
RemoveLink
remove link from chain
===============
*/
void RemoveLink( link_t *l )
{
l->next->prev = l->prev;
l->prev->next = l->next;
}
/*
===============
InsertLinkBefore
kept trigger and solid entities seperate
===============
*/
void InsertLinkBefore( link_t *l, link_t *before )
{
l->next = before;
l->prev = before->prev;
l->prev->next = l;
l->next->prev = l;
}
/*
==================
World_MoveBounds

View File

@@ -35,13 +35,6 @@ ENTITY AREA CHECKING
#include "lightstyle.h"
extern const char *et_name[];
// linked list
void InsertLinkBefore( link_t *l, link_t *before );
void RemoveLink( link_t *l );
void ClearLink( link_t *l );
// trace common
void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs );
void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t maxs, vec3_t outmins, vec3_t outmaxs );

View File

@@ -357,13 +357,17 @@ SDLash_InputEvent
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
static void SDLash_InputEvent( SDL_TextInputEvent input )
{
char *text;
const char *text;
VGui_ReportTextInput( input.text );
for( text = input.text; *text; text++ )
{
int ch;
int ch = (byte)*text;
ch = Con_UtfProcessChar((byte)*text );
// do not pass UTF-8 sequence into the engine, convert it here
if( !cls.accept_utf8 )
ch = Con_UtfProcessCharForce( ch );
if( !ch )
continue;
@@ -453,7 +457,7 @@ SDLash_EventFilter
=============
*/
static void SDLash_EventFilter( SDL_Event *event )
static void SDLash_EventHandler( SDL_Event *event )
{
switch ( event->type )
{
@@ -684,7 +688,7 @@ void Platform_RunEvents( void )
SDL_Event event;
while( !host.crashed && !host.shutdown_issued && SDL_PollEvent( &event ) )
SDLash_EventFilter( &event );
SDLash_EventHandler( &event );
#if XASH_PSVITA
PSVita_InputUpdate();

View File

@@ -843,6 +843,8 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode )
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
Uint32 flags = 0;
Q_strncpy( wndname, GI->title, sizeof( wndname ));
if( window_mode != WINDOW_MODE_WINDOWED )
SetBits( flags, SDL_FULLSCREEN|SDL_HWSURFACE );

View File

@@ -475,6 +475,7 @@ extern convar_t sv_fullupdate_penalty_time;
extern convar_t sv_log_outofband;
extern convar_t sv_allow_autoaim;
extern convar_t sv_aim;
extern convar_t sv_allow_testpacket;
//===========================================================
//
@@ -503,6 +504,7 @@ void SV_ActivateServer( int runPhysics );
qboolean SV_SpawnServer( const char *server, const char *startspot, qboolean background );
model_t *SV_ModelHandle( int modelindex );
void SV_DeactivateServer( void );
void SV_FreeTestPacket( void );
//
// sv_phys.c

View File

@@ -108,7 +108,7 @@ static void SV_GetChallenge( netadr_t from )
if( i == MAX_CHALLENGES )
{
// this is the first time this client has asked for a challenge
svs.challenges[oldest].challenge = (COM_RandomLong( 0, 0xFFFF ) << 16) | COM_RandomLong( 0, 0xFFFF );
svs.challenges[oldest].challenge = (COM_RandomLong( 0, 0x7FFF ) << 16) | COM_RandomLong( 0, 0xFFFF );
svs.challenges[oldest].adr = from;
svs.challenges[oldest].time = host.realtime;
svs.challenges[oldest].connected = false;
@@ -852,7 +852,7 @@ static void SV_TestBandWidth( netadr_t from )
}
// quickly reject invalid packets
if( !svs.testpacket_buf ||
if( !sv_allow_testpacket.value || !svs.testpacket_buf ||
( packetsize <= FRAGMENT_MIN_SIZE ) ||
( packetsize > FRAGMENT_MAX_SIZE ))
{
@@ -2035,7 +2035,7 @@ static qboolean SV_Kill_f( sv_client_t *cl )
{
if( !SV_IsValidEdict( cl->edict ))
return true;
if( cl->state != cs_spawned )
{
SV_ClientPrintf( cl, "Can't suicide - not connected!\n" );
@@ -2424,7 +2424,7 @@ static qboolean SV_EntList_f( sv_client_t *cl )
// filter by string
if( Cmd_Argc() > 1 )
{
{
if( !Q_stricmpext( Cmd_Argv( 1 ), STRING( ent->v.classname ) ) && !Q_stricmpext( Cmd_Argv( 1 ), STRING( ent->v.targetname ) ) )
continue;
}

View File

@@ -30,10 +30,8 @@ GNU General Public License for more details.
static int GAME_EXPORT pfnModelIndex( const char *m );
// fatpvs stuff
static byte fatpvs[MAX_MAP_LEAFS/8];
static byte fatphs[MAX_MAP_LEAFS/8];
static byte clientpvs[MAX_MAP_LEAFS/8]; // for find client in PVS
static vec3_t viewPoint[MAX_CLIENTS];
static byte fatphs[(MAX_MAP_LEAFS+7)/8];
static byte clientpvs[(MAX_MAP_LEAFS+7)/8]; // for find client in PVS
// exports
typedef void (__cdecl *LINK_ENTITY_FUNC)( entvars_t *pev );
@@ -258,7 +256,7 @@ void GAME_EXPORT SV_SetModel( edict_t *ent, const char *modelname )
return;
}
if( !modelname || modelname[0] <= ' ' )
if( !modelname || ((byte)modelname[0] ) <= ' ' )
{
Con_Printf( S_WARN "SV_SetModel: null name\n" );
return;
@@ -339,11 +337,12 @@ static qboolean SV_CheckClientVisiblity( sv_client_t *cl, const byte *mask )
if( !mask ) return true; // GoldSrc rules
clientnum = cl - svs.clients;
VectorCopy( viewPoint[clientnum], vieworg );
// Invasion issues: wrong camera position received in ENGINE_SET_PVS
if( cl->pViewEntity && !VectorCompare( vieworg, cl->pViewEntity->v.origin ))
if( cl->pViewEntity )
VectorCopy( cl->pViewEntity->v.origin, vieworg );
else
VectorCopy( cl->edict->v.origin, vieworg );
leaf = Mod_PointInLeaf( vieworg, sv.worldmodel->nodes );
@@ -422,7 +421,7 @@ static int SV_Multicast( int dest, const vec3_t origin, const edict_t *ent, qboo
case MSG_PAS:
if( origin == NULL ) return false;
// NOTE: GoldSource not using PHS for singleplayer
Mod_FatPVS( origin, FATPHS_RADIUS, fatphs, world.fatbytes, false, ( svs.maxclients == 1 ));
Mod_FatPVS( origin, FATPHS_RADIUS, fatphs, world.fatbytes, false, ( svs.maxclients == 1 ), true );
mask = fatphs; // using the FatPVS like a PHS
break;
case MSG_PVS_R:
@@ -4157,7 +4156,7 @@ void GAME_EXPORT SV_PlaybackEventFull( int flags, const edict_t *pInvoker, word
// setup pvs cluster for invoker
if( !FBitSet( flags, FEV_GLOBAL ))
{
Mod_FatPVS( pvspoint, FATPHS_RADIUS, fatphs, world.fatbytes, false, ( svs.maxclients == 1 ));
Mod_FatPVS( pvspoint, FATPHS_RADIUS, fatphs, world.fatbytes, false, ( svs.maxclients == 1 ), true );
mask = fatphs; // using the FatPVS like a PHS
}
@@ -4278,43 +4277,16 @@ so we can't use a single PVS point
*/
static byte *GAME_EXPORT pfnSetFatPVS( const float *org )
{
qboolean fullvis = false;
static byte fatpvs[(MAX_MAP_LEAFS+7)/8];
qboolean fullvis = false, merge = false;
if( !sv.worldmodel->visdata || sv_novis.value || !org || CL_DisableVisibility( ))
fullvis = true;
// portals can't change viewpoint!
if( !FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY ))
{
vec3_t viewPos, offset;
qboolean client_active = pfnGetCurrentPlayer() != -1;
if( FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY ))
merge = true;
// see code from client.cpp for understanding:
// org = pView->v.origin + pView->v.view_ofs;
// if ( pView->v.flags & FL_DUCKING )
// {
// org = org + ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN );
// }
// so we have unneeded duck calculations who have affect when player
// is ducked into water. Remove offset to restore right PVS position
if( client_active && FBitSet( sv.current_client->edict->v.flags, FL_DUCKING ))
{
VectorSubtract( svgame.pmove->player_mins[0], svgame.pmove->player_mins[1], offset );
VectorSubtract( org, offset, viewPos );
}
else VectorCopy( org, viewPos );
// build a new PVS frame
Mod_FatPVS( viewPos, FATPVS_RADIUS, fatpvs, world.fatbytes, false, fullvis );
if( client_active )
VectorCopy( viewPos, viewPoint[pfnGetCurrentPlayer()] );
}
else
{
// merge PVS
Mod_FatPVS( org, FATPVS_RADIUS, fatpvs, world.fatbytes, true, fullvis );
}
Mod_FatPVS( org, FATPVS_RADIUS, fatpvs, world.fatbytes, merge, fullvis, false );
return fatpvs;
}
@@ -4329,40 +4301,15 @@ so we can't use a single PHS point
*/
static byte *GAME_EXPORT pfnSetFatPAS( const float *org )
{
qboolean fullvis = false;
qboolean fullvis = false, merge = false;
if( !sv.worldmodel->visdata || sv_novis.value || !org || CL_DisableVisibility( ))
fullvis = true;
// portals can't change viewpoint!
if( !FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY ))
{
vec3_t viewPos, offset;
qboolean client_active = pfnGetCurrentPlayer() != -1;
if( FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY ))
merge = true;
// see code from client.cpp for understanding:
// org = pView->v.origin + pView->v.view_ofs;
// if ( pView->v.flags & FL_DUCKING )
// {
// org = org + ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN );
// }
// so we have unneeded duck calculations who have affect when player
// is ducked into water. Remove offset to restore right PVS position
if( client_active && FBitSet( sv.current_client->edict->v.flags, FL_DUCKING ))
{
VectorSubtract( svgame.pmove->player_mins[0], svgame.pmove->player_mins[1], offset );
VectorSubtract( org, offset, viewPos );
}
else VectorCopy( org, viewPos );
// build a new PHS frame
Mod_FatPVS( viewPos, FATPHS_RADIUS, fatphs, world.fatbytes, false, fullvis );
}
else
{
// merge PHS
Mod_FatPVS( org, FATPHS_RADIUS, fatphs, world.fatbytes, true, fullvis );
}
Mod_FatPVS( org, FATPHS_RADIUS, fatphs, world.fatbytes, merge, fullvis, true );
return fatphs;
}

View File

@@ -906,6 +906,21 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multipla
return 1;
}
void SV_FreeTestPacket( void )
{
if( svs.testpacket_buf )
{
Mem_Free( svs.testpacket_buf );
svs.testpacket_buf = NULL;
}
if( svs.testpacket_crcs )
{
Mem_Free( svs.testpacket_crcs );
svs.testpacket_crcs = NULL;
}
}
/*
================
SV_GenerateTestPacket
@@ -917,7 +932,13 @@ static void SV_GenerateTestPacket( void )
uint32_t crc;
file_t *file;
byte *filepos;
int i, filesize;
int i;
if( !sv_allow_testpacket.value )
{
SV_FreeTestPacket();
return;
}
// testpacket already generated once, exit
// testpacket and lookup table takes ~300k of memory

View File

@@ -48,7 +48,7 @@ CVAR_DEFINE_AUTO( sv_proxies, "1", FCVAR_SERVER, "maximum count of allowed proxi
CVAR_DEFINE_AUTO( sv_send_logos, "1", 0, "send custom decal logo to other players so they can view his too" );
CVAR_DEFINE_AUTO( sv_send_resources, "1", 0, "allow to download missed resources for players" );
CVAR_DEFINE_AUTO( sv_logbans, "0", 0, "print into the server log info about player bans" );
CVAR_DEFINE_AUTO( sv_allow_upload, "1", FCVAR_SERVER, "allow uploading custom resources on a server" );
CVAR_DEFINE( sv_allow_upload, "sv_allowupload", "1", FCVAR_SERVER, "allow uploading custom resources on a server" );
CVAR_DEFINE( sv_allow_download, "sv_allowdownload", "1", FCVAR_SERVER, "allow downloading custom resources to the client" );
static CVAR_DEFINE_AUTO( sv_allow_dlfile, "1", 0, "compatibility cvar, does nothing" );
CVAR_DEFINE_AUTO( sv_uploadmax, "0.5", FCVAR_SERVER, "max size to upload custom resources (500 kB as default)" );
@@ -150,6 +150,8 @@ CVAR_DEFINE_AUTO( sv_userinfo_penalty_attempts, "4", FCVAR_ARCHIVE, "if max atte
CVAR_DEFINE_AUTO( sv_fullupdate_penalty_time, "1", FCVAR_ARCHIVE, "allow fullupdate command only once in this timewindow (set 0 to disable)" );
CVAR_DEFINE_AUTO( sv_log_outofband, "0", FCVAR_ARCHIVE, "log out of band messages, can be useful for server admins and for engine debugging" );
CVAR_DEFINE_AUTO( sv_allow_testpacket, "1", FCVAR_ARCHIVE, "allow generating and sending a big blob of data to test maximum packet size" );
//============================================================================
/*
================
@@ -973,6 +975,7 @@ void SV_Init( void )
Cvar_RegisterVariable( &sv_userinfo_penalty_attempts );
Cvar_RegisterVariable( &sv_fullupdate_penalty_time );
Cvar_RegisterVariable( &sv_log_outofband );
Cvar_RegisterVariable( &sv_allow_testpacket );
// when we in developer-mode automatically turn cheats on
if( host_developer.value ) Cvar_SetValue( "sv_cheats", 1.0f );
@@ -1115,6 +1118,9 @@ void SV_Shutdown( const char *finalmsg )
SV_FreeClients();
svs.maxclients = 0;
// release test packet blob
SV_FreeTestPacket();
// release all models
Mod_FreeAll();

View File

@@ -358,6 +358,53 @@ static hull_t *SV_HullForStudioModel( edict_t *ent, vec3_t mins, vec3_t maxs, ve
return SV_HullForEntity( ent, mins, maxs, offset );
}
/*
===============================================================================
ENTITY LINKING
===============================================================================
*/
/*
===============
ClearLink
ClearLink is used for new headnodes
===============
*/
static void ClearLink( link_t *l )
{
l->prev = l->next = l;
}
/*
===============
RemoveLink
remove link from chain
===============
*/
static void RemoveLink( link_t *l )
{
l->next->prev = l->prev;
l->prev->next = l->next;
}
/*
===============
InsertLinkBefore
kept trigger and solid entities seperate
===============
*/
static void InsertLinkBefore( link_t *l, link_t *before )
{
l->next = before;
l->prev = before->prev;
l->prev->next = l;
l->next->prev = l;
}
/*
===============================================================================

View File

@@ -2425,7 +2425,7 @@ static void *FS_CustomAlloc( size_t size )
static void FS_CustomFree( void *data )
{
return Mem_Free( data );
Mem_Free( data );
}
/*

View File

@@ -274,6 +274,13 @@ const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *need
return NULL;
}
void Q_memor( byte *XASH_RESTRICT dst, const byte *XASH_RESTRICT src, size_t len )
{
size_t i;
for( i = 0; i < len; i++ ) // msvc likes to optimize this loop form
dst[i] |= src[i];
}
const char* Q_timestamp( int format )
{
static string timestamp;

View File

@@ -45,6 +45,10 @@ enum
#define PFILE_TOKEN_MAX_LENGTH 1024
#define PFILE_FS_TOKEN_MAX_LENGTH 512
#ifdef __cplusplus
#define restrict
#endif // __cplusplus
//
// build.c
//
@@ -72,6 +76,7 @@ void Q_atov( float *vec, const char *str, size_t siz );
qboolean Q_stricmpext( const char *pattern, const char *text );
qboolean Q_strnicmpext( const char *pattern, const char *text, size_t minimumlen );
const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *needle, size_t needlelen );
void Q_memor( byte *XASH_RESTRICT dst, const byte *XASH_RESTRICT src, size_t len );
const char *Q_timestamp( int format );
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
int Q_snprintf( char *buffer, size_t buffersize, const char *format, ... ) _format( 3 );

View File

@@ -28,7 +28,7 @@ GNU General Public License for more details.
// REFTODO: rewrite in triapi
void R_DrawWorldHull( void )
{
hull_model_t *hull = &tr.world->hull_models[0];
hull_model_t *hull;
winding_t *poly;
int i;
@@ -42,6 +42,8 @@ void R_DrawWorldHull( void )
if( !r_showhull->value )
return;
hull = &tr.world->hull_models[0];
pglDisable( GL_TEXTURE_2D );
list_for_each_entry( poly, &hull->polys, chain )

View File

@@ -66,10 +66,10 @@ Draw_StretchPicImplementation
static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1, int t1, int s2, int t2, image_t *pic )
{
pixel_t *source, *dest;
unsigned int v, u, sv;
unsigned int u, sv;
unsigned int height;
unsigned int f, fstep;
int skip;
int skip, v;
qboolean transparent = false;
pixel_t *buffer;
@@ -212,9 +212,9 @@ void GAME_EXPORT R_DrawStretchPic( float x, float y, float w, float h, float s1,
void Draw_Fill (int x, int y, int w, int h)
{
pixel_t *dest;
unsigned int v, u;
unsigned int u;
unsigned int height;
int skip;
int skip, v;
pixel_t src = vid.color;
int alpha = vid.alpha;

View File

@@ -410,19 +410,10 @@ void R_EntityRemoveDecals( model_t *mod );
void R_ClearDecals( void );
void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[3] );
#if 0
//
// gl_drawhulls.c
//
void R_DrawWorldHull( void );
void R_DrawModelHull( void );
#endif
void GL_Bind( int tmu, unsigned int texnum );
//
// gl_draw.cM_PI
// gl_draw.c
//
void R_Set2DMode( qboolean enable );
void R_DrawTileClear( int texnum, int x, int y, int w, int h );

View File

@@ -122,9 +122,9 @@ POLLY_CFLAGS = {
}
OPENMP_CFLAGS = {
'gcc': ['-fopenmp'],
'clang': ['-fopenmp'],
'msvc': ['/openmp']
'gcc': ['-fopenmp', '-DHAVE_OPENMP=1'],
'clang': ['-fopenmp', '-DHAVE_OPENMP=1'],
'msvc': ['/openmp', '/DHAVE_OPENMP=1']
}
OPENMP_LINKFLAGS = {

12
waf vendored

File diff suppressed because one or more lines are too long

View File

@@ -25,7 +25,7 @@ Setlocal EnableDelayedExpansion
set PYTHON_DIR_OK=FALSE
set REGPATH=
for %%i in (3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5) do (
for %%i in (3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7) do (
for %%j in (HKCU HKLM) do (
for %%k in (SOFTWARE\Wow6432Node SOFTWARE) do (
for %%l in (Python\PythonCore IronPython) do (