2004-10-15 00:35:53 +00:00
//contains generic plugin code for dll/qvm
//it's this one or the engine...
# include "plugin.h"
2013-05-03 04:29:36 +00:00
typedef struct
{
2012-10-08 05:29:52 +00:00
const char * name ;
2004-10-15 00:35:53 +00:00
export_t func ;
} exports_t ;
extern exports_t exports [ 16 ] ;
2018-03-04 14:41:16 +00:00
qintptr_t NATIVEEXPORT vmMain ( qintptr_t command , qintptr_t arg0 , qintptr_t arg1 , qintptr_t arg2 , qintptr_t arg3 , qintptr_t arg4 , qintptr_t arg5 , qintptr_t arg6 , qintptr_t arg7 /*, qintptr_t arg8, qintptr_t arg9, qintptr_t arg10, qintptr_t arg11*/ )
2004-10-15 00:35:53 +00:00
{
2018-03-04 14:41:16 +00:00
qintptr_t args [ ] =
{
arg0 ,
arg1 ,
arg2 ,
arg3 ,
arg4 ,
arg5 ,
arg6 ,
arg7 ,
// arg8,
// arg9,
// arg10,
// arg11,
} ;
return exports [ command ] . func ( args ) ;
2004-10-15 00:35:53 +00:00
}
# ifndef Q3_VM
2012-10-08 05:29:52 +00:00
qintptr_t ( QDECL * plugin_syscall ) ( qintptr_t arg , . . . ) ;
2004-10-15 00:35:53 +00:00
# endif
# define PASSFLOAT(f) *(int*)&(f)
# define ARGNAMES ,funcname
2012-10-08 05:29:52 +00:00
BUILTINR ( funcptr_t , Plug_GetEngineFunction , ( const char * funcname ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,funcname,expnum
2018-10-11 10:31:23 +00:00
static BUILTINR ( int , Plug_ExportToEngine , ( const char * funcname , quintptr_t expnum ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2012-04-23 05:07:40 +00:00
# ifndef Q3_VM
# define ARGNAMES ,funcname,func
2012-10-08 05:29:52 +00:00
BUILTINR ( qboolean , Plug_ExportNative , ( const char * funcname , void * func ) ) ;
2012-04-23 05:07:40 +00:00
# undef ARGNAMES
2016-07-12 00:40:13 +00:00
# define ARGNAMES ,funcname
BUILTINR ( void * , Plug_GetNativePointer , ( const char * funcname ) ) ;
# undef ARGNAMES
2012-04-23 05:07:40 +00:00
# endif
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,text
2012-10-08 05:29:52 +00:00
BUILTIN ( void , Con_Print , ( const char * text ) ) ; //on to main console.
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2017-10-12 12:02:25 +00:00
# define ARGNAMES ,conname,flags
2018-03-04 14:41:16 +00:00
BUILTINR ( qhandle_t , Con_POpen , ( const char * conname , quintptr_t flags ) ) ;
2017-10-12 12:02:25 +00:00
# undef ARGNAMES
2005-07-20 11:50:00 +00:00
# define ARGNAMES ,conname,text
2013-03-31 04:21:08 +00:00
BUILTIN ( void , Con_SubPrint , ( const char * conname , const char * text ) ) ; //on to named sub console (creating it too).
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
2018-08-04 19:00:19 +00:00
# define ARGNAMES ,old,newname
BUILTIN ( void , Con_RenameSub , ( const char * old , const char * newname ) ) ; //rename a subconsole
2005-12-16 18:08:40 +00:00
# undef ARGNAMES
# define ARGNAMES ,conname
2015-04-21 04:12:00 +00:00
BUILTINR ( int , Con_IsActive , ( const char * conname ) ) ;
2005-12-16 18:08:40 +00:00
# undef ARGNAMES
# define ARGNAMES ,conname
2015-04-21 04:12:00 +00:00
BUILTIN ( void , Con_SetActive , ( const char * conname ) ) ;
2005-12-16 18:08:40 +00:00
# undef ARGNAMES
# define ARGNAMES ,conname
2015-04-21 04:12:00 +00:00
BUILTIN ( void , Con_Destroy , ( const char * conname ) ) ;
2005-12-16 18:08:40 +00:00
# undef ARGNAMES
# define ARGNAMES ,connum,conname,connamelen
2018-03-04 14:41:16 +00:00
BUILTIN ( void , Con_NameForNum , ( qintptr_t connum , char * conname , quintptr_t connamelen ) ) ;
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
2015-04-21 04:12:00 +00:00
# define ARGNAMES ,conname,attribname
BUILTINR ( float , Con_GetConsoleFloat , ( const char * conname , const char * attribname ) ) ;
# undef ARGNAMES
# define ARGNAMES ,conname,attribname,PASSFLOAT(newvalue)
BUILTIN ( void , Con_SetConsoleFloat , ( const char * conname , const char * attribname , float newvalue ) ) ;
# undef ARGNAMES
# define ARGNAMES ,conname,attribname,value,valuesize
2018-03-04 14:41:16 +00:00
BUILTINR ( int , Con_GetConsoleString , ( const char * conname , const char * attribname , const char * value , quintptr_t valuesize ) ) ;
2015-04-21 04:12:00 +00:00
# undef ARGNAMES
# define ARGNAMES ,conname,attribname,newvalue
BUILTIN ( void , Con_SetConsoleString , ( const char * conname , const char * attribname , const char * newvalue ) ) ;
# undef ARGNAMES
2005-07-20 11:50:00 +00:00
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,message
2015-06-12 14:44:50 +00:00
BUILTIN ( void , Sys_Error , ( const char * message ) ) ; //abort the entire engine.
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2005-07-20 11:50:00 +00:00
# define ARGNAMES
2018-03-04 14:41:16 +00:00
BUILTINR ( quintptr_t , Sys_Milliseconds , ( void ) ) ; //get the time the engine has been running.
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
2004-10-15 00:35:53 +00:00
2005-07-20 11:50:00 +00:00
# define ARGNAMES ,buffer
2015-06-12 14:44:50 +00:00
BUILTINR ( int , Cmd_AddCommand , ( const char * buffer ) ) ; //register a command.
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,buffer,bufsize
2005-12-06 15:40:52 +00:00
BUILTIN ( void , Cmd_Args , ( char * buffer , int bufsize ) ) ; //retrieve some arguments.
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,argnum,buffer,bufsize
2005-12-06 15:40:52 +00:00
BUILTIN ( void , Cmd_Argv , ( int argnum , char * buffer , int bufsize ) ) ; //retrieve a single argument at a time.
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES
2005-12-06 15:40:52 +00:00
BUILTINR ( int , Cmd_Argc , ( void ) ) ; //get the argument count.
2005-11-27 01:12:16 +00:00
# undef ARGNAMES
# define ARGNAMES ,msg
2018-10-11 10:31:23 +00:00
BUILTIN ( void , Cmd_TokenizeString , ( const char * msg ) ) ; //tokenize a string.
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,text,insert
2015-06-12 14:44:50 +00:00
BUILTIN ( void , Cmd_AddText , ( const char * text , qboolean insert ) ) ; //add stuff to the console input.
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,name,value
2015-08-24 03:54:39 +00:00
BUILTIN ( void , Cvar_SetString , ( const char * name , const char * value ) ) ; //set a cvar string
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2005-12-06 15:40:52 +00:00
# define ARGNAMES ,name,PASSFLOAT(value)
2015-06-12 14:44:50 +00:00
BUILTIN ( void , Cvar_SetFloat , ( const char * name , float value ) ) ; //set a cvar float
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,name,retstring,sizeofretstring
2018-03-04 14:41:16 +00:00
BUILTINR ( qboolean , Cvar_GetString , ( const char * name , char * retstring , quintptr_t sizeofretstring ) ) ; //retrieve a cvar string
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,name
2015-06-12 14:44:50 +00:00
BUILTINR ( float , Cvar_GetFloat , ( const char * name ) ) ; //get a cvar's value
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,name,defaultval,flags,grouphint
2015-06-12 14:44:50 +00:00
BUILTINR ( qhandle_t , Cvar_Register , ( const char * name , const char * defaultval , int flags , const char * grouphint ) ) ; //register a new cvar
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,handle,modificationcount,stringv,floatv
2005-11-27 01:12:16 +00:00
BUILTINR ( int , Cvar_Update , ( qhandle_t handle , int * modificationcount , char * stringv , float * floatv ) ) ; //stringv is 256 chars long, don't expect this function to do anything if modification count is unchanged.
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
# if !defined(Q3_VM) && defined(FTEPLUGIN)
# define ARGNAMES ,name,defaultval,flags,description,groupname
BUILTINR ( cvar_t * , Cvar_GetNVFDG , ( const char * name , const char * defaultval , unsigned int flags , const char * description , const char * groupname ) ) ;
# undef ARGNAMES
# endif
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,pnum,stats,maxstats
2013-03-31 04:21:08 +00:00
BUILTINR ( int , CL_GetStats , ( int pnum , unsigned int * stats , int maxstats ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2006-01-21 00:07:47 +00:00
# define ARGNAMES ,pnum,info
2007-08-11 15:20:35 +00:00
BUILTINR ( int , GetPlayerInfo , ( int pnum , plugclientinfo_t * info ) ) ;
2006-01-21 00:07:47 +00:00
# undef ARGNAMES
2007-09-17 20:54:26 +00:00
# define ARGNAMES
BUILTINR ( int , LocalPlayerNumber , ( void ) ) ;
# undef ARGNAMES
2015-04-21 04:12:00 +00:00
# define ARGNAMES ,firstseat,numseats,playernums,spectracks
BUILTINR ( int , GetLocalPlayerNumbers , ( int firstseat , int numseats , int * playernums , int * spectracks ) ) ;
# undef ARGNAMES
2007-09-17 20:54:26 +00:00
# define ARGNAMES ,info,infolen
BUILTIN ( void , GetServerInfo , ( char * info , int infolen ) ) ;
# undef ARGNAMES
# define ARGNAMES ,key,value
2015-06-12 14:44:50 +00:00
BUILTIN ( void , SetUserInfo , ( const char * key , const char * value ) ) ;
2007-09-17 20:54:26 +00:00
# undef ARGNAMES
2015-11-18 07:37:39 +00:00
# ifdef FTEPLUGIN
2015-10-27 15:20:15 +00:00
# define ARGNAMES ,seat,playercmd
BUILTINR ( int , GetLastInputFrame , ( int seat , usercmd_t * playercmd ) ) ;
# undef ARGNAMES
2015-11-18 07:37:39 +00:00
# endif
2015-10-27 15:20:15 +00:00
# define ARGNAMES ,seat,text,textsize
BUILTINR ( float , GetTrackerOwnFrags , ( int seat , char * text , size_t textsize ) ) ;
# undef ARGNAMES
2019-06-21 03:59:46 +00:00
# define ARGNAMES ,packagename,mapname,stats
BUILTINR ( qboolean , MapLog_Query , ( const char * packagename , const char * mapname , float * stats ) ) ;
# undef ARGNAMES
2016-07-12 00:40:13 +00:00
# ifndef Q3_VM
# define ARGNAMES ,vmid
BUILTINR ( struct pubprogfuncs_s * , PR_GetVMInstance , ( int vmid /*0=ss,1=cs,2=m*/ ) ) ;
# undef ARGNAMES
# ifdef MULTITHREAD
# define ARGNAMES ,threadingsize
BUILTINR ( struct threading_s * , Sys_GetThreadingFuncs , ( int threadingsize ) ) ;
# undef ARGNAMES
# endif
# define ARGNAMES ,version
BUILTINR ( struct modplugfuncs_s * , Mod_GetPluginModelFuncs , ( int version ) ) ;
# undef ARGNAMES
# endif
2004-10-15 00:35:53 +00:00
2007-10-05 10:50:13 +00:00
# define ARGNAMES ,pos,buffer,bufferlen
2015-06-12 14:44:50 +00:00
BUILTIN ( void , GetLocationName , ( const float * pos , char * buffer , int bufferlen ) ) ;
2007-10-05 10:50:13 +00:00
# undef ARGNAMES
2015-06-29 23:46:31 +00:00
# define ARGNAMES ,clients,maxclients,showenemies,showself
BUILTINR ( int , GetTeamInfo , ( teamplayerinfo_t * clients , unsigned int maxclients , int showenemies , int showself ) ) ;
# undef ARGNAMES
2015-10-27 15:20:15 +00:00
# define ARGNAMES ,player,result,maxresults
BUILTINR ( int , GetWeaponStats , ( int player , struct wstats_s * result , unsigned int maxresults ) ) ;
# undef ARGNAMES
2015-06-29 23:46:31 +00:00
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,soundname
2015-06-12 14:44:50 +00:00
BUILTIN ( void , LocalSound , ( const char * soundname ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2005-12-15 18:52:03 +00:00
# define ARGNAMES ,plugnum, buffer, bufsize
2015-08-24 03:54:39 +00:00
BUILTIN ( void , Plug_GetPluginName , ( int plugnum , char * buffer , int bufsize ) ) ;
2005-12-15 18:52:03 +00:00
# undef ARGNAMES
2015-04-21 04:12:00 +00:00
# define ARGNAMES ,ni,sizeofni
BUILTINR ( int , GetNetworkInfo , ( vmnetinfo_t * ni , unsigned int sizeofni ) ) ;
# undef ARGNAMES
2013-11-21 23:02:28 +00:00
# define ARGNAMES ,name,mime,data,datalen
2015-04-21 04:12:00 +00:00
BUILTINR ( qhandle_t , Draw_LoadImageData , ( const char * name , const char * mime , const void * data , unsigned int datalen ) ) ; //force-replace a texture.
2013-11-21 23:02:28 +00:00
# undef ARGNAMES
# define ARGNAMES ,name,shaderscript
2015-04-21 04:12:00 +00:00
BUILTINR ( qhandle_t , Draw_LoadImageShader , ( const char * name , const char * shaderscript ) ) ; //some shader script
2013-11-21 23:02:28 +00:00
# undef ARGNAMES
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,name,iswadimage
2015-04-21 04:12:00 +00:00
BUILTINR ( qhandle_t , Draw_LoadImage , ( const char * name , qboolean iswadimage ) ) ; //wad image is ONLY for loading out of q1 gfx.wad
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
# define ARGNAMES ,PASSFLOAT(x),PASSFLOAT(y),PASSFLOAT(w),PASSFLOAT(h),PASSFLOAT(s1),PASSFLOAT(t1),PASSFLOAT(s2),PASSFLOAT(t2),image
2007-08-11 15:20:35 +00:00
BUILTINR ( int , Draw_Image , ( float x , float y , float w , float h , float s1 , float t1 , float s2 , float t2 , qhandle_t image ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2015-04-21 04:12:00 +00:00
# define ARGNAMES ,image,x,y
BUILTINR ( int , Draw_ImageSize , ( qhandle_t image , float * x , float * y ) ) ;
# undef ARGNAMES
2005-12-10 00:19:24 +00:00
# define ARGNAMES ,PASSFLOAT(x1),PASSFLOAT(y1),PASSFLOAT(x2),PASSFLOAT(y2)
BUILTIN ( void , Draw_Line , ( float x1 , float y1 , float x2 , float y2 ) ) ;
# undef ARGNAMES
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,PASSFLOAT(x),PASSFLOAT(y),PASSFLOAT(w),PASSFLOAT(h)
2006-01-13 06:11:47 +00:00
BUILTIN ( void , Draw_Fill , ( float x , float y , float w , float h ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2013-11-21 23:02:28 +00:00
# define ARGNAMES ,x,y,character
BUILTIN ( void , Draw_Character , ( int x , int y , unsigned int character ) ) ;
# undef ARGNAMES
# define ARGNAMES ,PASSFLOAT(x),PASSFLOAT(y),string
2015-04-21 04:12:00 +00:00
BUILTIN ( void , Draw_String , ( float x , float y , const char * string ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2015-06-17 13:05:20 +00:00
# define ARGNAMES ,PASSFLOAT(x),PASSFLOAT(y),PASSFLOAT(h),flags,character
BUILTIN ( void , Draw_CharacterH , ( float x , float y , float h , unsigned int flags , unsigned int character ) ) ;
# undef ARGNAMES
# define ARGNAMES ,PASSFLOAT(x),PASSFLOAT(y),PASSFLOAT(h),flags,string
BUILTIN ( void , Draw_StringH , ( float x , float y , float h , unsigned int flags , const char * string ) ) ;
# undef ARGNAMES
2015-10-27 15:20:15 +00:00
# define ARGNAMES ,PASSFLOAT(h),flags,string
BUILTINR ( float , Draw_StringWidth , ( float h , unsigned int flags , const char * string ) ) ;
# undef ARGNAMES
2015-06-17 13:05:20 +00:00
# define ARGNAMES ,palcol,PASSFLOAT(a)
BUILTIN ( void , Draw_Colourpa , ( int palcol , float a ) ) ;
# undef ARGNAMES
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,palcol
BUILTIN ( void , Draw_Colourp , ( int palcol ) ) ;
# undef ARGNAMES
# define ARGNAMES ,PASSFLOAT(r),PASSFLOAT(g),PASSFLOAT(b)
BUILTIN ( void , Draw_Colour3f , ( float r , float g , float b ) ) ;
# undef ARGNAMES
# define ARGNAMES ,PASSFLOAT(r),PASSFLOAT(g),PASSFLOAT(b),PASSFLOAT(a)
BUILTIN ( void , Draw_Colour4f , ( float r , float g , float b , float a ) ) ;
# undef ARGNAMES
2005-11-27 01:12:16 +00:00
# define ARGNAMES ,s
2016-07-12 00:40:13 +00:00
BUILTIN ( void , SCR_CenterPrint , ( const char * s ) ) ;
2005-11-27 01:12:16 +00:00
# undef ARGNAMES
2004-10-15 00:35:53 +00:00
# define ARGNAMES ,mnum
BUILTIN ( void , Menu_Control , ( int mnum ) ) ;
# undef ARGNAMES
# define ARGNAMES ,keyname
2016-07-12 00:40:13 +00:00
BUILTINR ( int , Key_GetKeyCode , ( const char * keyname ) ) ;
2004-10-15 00:35:53 +00:00
# undef ARGNAMES
2014-10-05 20:04:11 +00:00
# if !defined(Q3_VM) && defined(FTEPLUGIN)
# define ARGNAMES ,name,handle,mode
2016-07-12 00:40:13 +00:00
BUILTINR ( qboolean , VFS_Open , ( const char * name , vfsfile_t * * handle , const char * mode ) ) ; //opens a direct vfs file. no access checks, and so can be used in threaded plugins
# undef ARGNAMES
# define ARGNAMES ,name,relativeto,out,outlen
BUILTINR ( qboolean , FS_NativePath , ( const char * name , enum fs_relative relativeto , char * out , int outlen ) ) ;
2014-10-05 20:04:11 +00:00
# undef ARGNAMES
# endif
2005-11-30 00:48:29 +00:00
# define ARGNAMES ,name,handle,mode
2016-07-12 00:40:13 +00:00
BUILTINR ( int , FS_Open , ( const char * name , qhandle_t * handle , int mode ) ) ;
2005-11-30 00:48:29 +00:00
# undef ARGNAMES
# define ARGNAMES ,handle
2005-12-06 15:40:52 +00:00
BUILTIN ( void , FS_Close , ( qhandle_t handle ) ) ;
2005-11-30 00:48:29 +00:00
# undef ARGNAMES
# define ARGNAMES ,handle,data,len
2005-12-06 15:40:52 +00:00
BUILTINR ( int , FS_Write , ( qhandle_t handle , void * data , int len ) ) ;
2005-11-30 00:48:29 +00:00
# undef ARGNAMES
# define ARGNAMES ,handle,data,len
2005-12-06 15:40:52 +00:00
BUILTINR ( int , FS_Read , ( qhandle_t handle , void * data , int len ) ) ;
2005-11-30 00:48:29 +00:00
# undef ARGNAMES
2013-05-03 04:29:36 +00:00
# define ARGNAMES ,handle,offsetlow,offsethigh
BUILTINR ( int , FS_Seek , ( qhandle_t handle , unsigned int offsetlow , unsigned int offsethigh ) ) ;
# undef ARGNAMES
2016-07-12 00:40:13 +00:00
# define ARGNAMES ,handle,sizelow,sizehigh
BUILTINR ( qboolean , FS_GetLen , ( qhandle_t handle , unsigned int * sizelow , unsigned int * sizehigh ) ) ;
# undef ARGNAMES
2005-11-30 00:48:29 +00:00
2005-07-20 11:50:00 +00:00
# define ARGNAMES ,ip,port
2005-12-06 15:40:52 +00:00
BUILTINR ( qhandle_t , Net_TCPConnect , ( char * ip , int port ) ) ;
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
# define ARGNAMES ,ip,port,maxcount
2005-12-06 15:40:52 +00:00
BUILTINR ( qhandle_t , Net_TCPListen , ( char * ip , int port , int maxcount ) ) ;
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
# define ARGNAMES ,socket,address,addresslen
2005-12-06 15:40:52 +00:00
BUILTINR ( qhandle_t , Net_Accept , ( qhandle_t socket , char * address , int addresslen ) ) ;
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
# define ARGNAMES ,socket,buffer,len
2005-12-06 15:40:52 +00:00
BUILTINR ( int , Net_Recv , ( qhandle_t socket , void * buffer , int len ) ) ;
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
# define ARGNAMES ,socket,buffer,len
2005-12-06 15:40:52 +00:00
BUILTINR ( int , Net_Send , ( qhandle_t socket , void * buffer , int len ) ) ;
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
# define ARGNAMES ,socket
2005-12-06 15:40:52 +00:00
BUILTIN ( void , Net_Close , ( qhandle_t socket ) ) ;
2005-07-20 11:50:00 +00:00
# undef ARGNAMES
2016-07-12 00:40:13 +00:00
# define ARGNAMES ,sock,certhostname
BUILTINR ( int , Net_SetTLSClient , ( qhandle_t sock , const char * certhostname ) ) ;
# undef ARGNAMES
2017-09-20 11:27:13 +00:00
# define ARGNAMES ,sock,outdata,datalen
BUILTINR ( int , Net_GetTLSBinding , ( qhandle_t sock , char * outdata , int * datalen ) ) ;
# undef ARGNAMES
2005-07-20 11:50:00 +00:00
2009-04-19 01:46:52 +00:00
# define ARGNAMES ,inputbuffer,buffersize
BUILTINR ( int , ReadInputBuffer , ( void * inputbuffer , int buffersize ) ) ;
# undef ARGNAMES
# define ARGNAMES ,inputbuffer,bytes
BUILTINR ( int , UpdateInputBuffer , ( void * inputbuffer , int bytes ) ) ;
# undef ARGNAMES
2005-07-20 11:50:00 +00:00
# ifdef Q3_VM
# define ARGNAMES ,out,in,len
BUILTIN ( void , memcpy , ( void * out , void * in , int len ) ) ;
# undef ARGNAMES
# define ARGNAMES ,out,in,len
BUILTIN ( void , memset , ( void * out , int in , int len ) ) ;
# undef ARGNAMES
2005-11-27 01:12:16 +00:00
# define ARGNAMES ,out,in,len
BUILTIN ( void , memmove , ( void * out , void * in , int len ) ) ;
# undef ARGNAMES
2005-12-06 15:40:52 +00:00
# define ARGNAMES ,PASSFLOAT(f)
BUILTINR ( float , sqrt , ( float f ) ) ;
2005-12-10 00:19:24 +00:00
BUILTINR ( float , sin , ( float f ) ) ;
BUILTINR ( float , cos , ( float f ) ) ;
2005-12-06 15:40:52 +00:00
# undef ARGNAMES
2005-07-20 11:50:00 +00:00
# endif
2009-04-19 01:46:52 +00:00
2013-11-29 14:36:47 +00:00
char * va ( const char * format , . . . ) //Identical in function to the one in Quake, though I can assure you that I wrote it...
2004-10-15 00:35:53 +00:00
{ //It's not exactly hard, just easy to use, so gets duplicated lots.
va_list argptr ;
static char string [ 1024 ] ;
va_start ( argptr , format ) ;
2015-04-21 04:12:00 +00:00
# ifdef Q3_VM
2013-06-23 18:43:59 +00:00
Q_vsnprintf ( string , sizeof ( string ) , format , argptr ) ;
2015-04-21 04:12:00 +00:00
# else
# ifdef _WIN32
# undef _vsnprintf
_vsnprintf ( string , sizeof ( string ) , format , argptr ) ;
string [ sizeof ( string ) - 1 ] = 0 ;
# else
vsnprintf ( string , sizeof ( string ) , format , argptr ) ;
# endif
# endif
2004-10-15 00:35:53 +00:00
va_end ( argptr ) ;
return string ;
}
2012-10-08 05:29:52 +00:00
void Con_Printf ( const char * format , . . . )
2004-10-15 00:35:53 +00:00
{
va_list argptr ;
static char string [ 1024 ] ;
va_start ( argptr , format ) ;
2013-06-23 18:43:59 +00:00
Q_vsnprintf ( string , sizeof ( string ) , format , argptr ) ;
2004-10-15 00:35:53 +00:00
va_end ( argptr ) ;
2013-05-03 04:29:36 +00:00
pCon_Print ( string ) ;
2004-10-15 00:35:53 +00:00
}
2012-11-27 03:23:19 +00:00
void Con_DPrintf ( const char * format , . . . )
{
va_list argptr ;
static char string [ 1024 ] ;
2013-05-03 04:29:36 +00:00
if ( ! pCvar_GetFloat ( " developer " ) )
2012-11-27 03:23:19 +00:00
return ;
va_start ( argptr , format ) ;
2013-06-23 18:43:59 +00:00
Q_vsnprintf ( string , sizeof ( string ) , format , argptr ) ;
2012-11-27 03:23:19 +00:00
va_end ( argptr ) ;
2013-05-03 04:29:36 +00:00
pCon_Print ( string ) ;
2012-11-27 03:23:19 +00:00
}
2012-10-08 05:29:52 +00:00
void Sys_Errorf ( const char * format , . . . )
2004-10-15 00:35:53 +00:00
{
va_list argptr ;
static char string [ 1024 ] ;
va_start ( argptr , format ) ;
2013-06-23 18:43:59 +00:00
Q_vsnprintf ( string , sizeof ( string ) , format , argptr ) ;
2004-10-15 00:35:53 +00:00
va_end ( argptr ) ;
2013-05-03 04:29:36 +00:00
pSys_Error ( string ) ;
2004-10-15 00:35:53 +00:00
}
2018-10-11 10:31:23 +00:00
static void Plug_InitStandardBuiltins ( void )
2004-10-15 00:35:53 +00:00
{
2005-12-01 01:16:55 +00:00
//con_print is used if the others don't exist, and MUST come first (for the sake of sanity)
CHECKBUILTIN ( Con_Print ) ;
CHECKBUILTIN ( Plug_ExportToEngine ) ;
2012-04-23 05:07:40 +00:00
# ifndef Q3_VM
CHECKBUILTIN ( Plug_ExportNative ) ;
2016-07-12 00:40:13 +00:00
CHECKBUILTIN ( Plug_GetNativePointer ) ;
2012-04-23 05:07:40 +00:00
# endif
2005-12-01 01:16:55 +00:00
CHECKBUILTIN ( Sys_Error ) ;
2009-04-19 01:46:52 +00:00
CHECKBUILTIN ( ReadInputBuffer ) ;
CHECKBUILTIN ( UpdateInputBuffer ) ;
2005-07-20 11:50:00 +00:00
# ifdef Q3_VM
CHECKBUILTIN ( memcpy ) ;
2005-11-27 01:12:16 +00:00
CHECKBUILTIN ( memmove ) ;
2005-07-20 11:50:00 +00:00
CHECKBUILTIN ( memset ) ;
2005-12-06 15:40:52 +00:00
CHECKBUILTIN ( sqrt ) ;
2005-12-10 00:19:24 +00:00
CHECKBUILTIN ( sin ) ;
CHECKBUILTIN ( cos ) ;
2005-07-20 11:50:00 +00:00
# endif
CHECKBUILTIN ( Sys_Milliseconds ) ;
2004-10-15 00:35:53 +00:00
2005-07-20 11:50:00 +00:00
//command execution
CHECKBUILTIN ( Cmd_AddCommand ) ;
2004-10-15 00:35:53 +00:00
CHECKBUILTIN ( Cmd_Args ) ;
CHECKBUILTIN ( Cmd_Argv ) ;
CHECKBUILTIN ( Cmd_Argc ) ;
CHECKBUILTIN ( Cmd_AddText ) ;
2005-07-20 11:50:00 +00:00
//cvar stuff
2004-10-15 00:35:53 +00:00
CHECKBUILTIN ( Cvar_SetString ) ;
CHECKBUILTIN ( Cvar_SetFloat ) ;
CHECKBUILTIN ( Cvar_GetString ) ;
CHECKBUILTIN ( Cvar_GetFloat ) ;
CHECKBUILTIN ( Cvar_Register ) ;
CHECKBUILTIN ( Cvar_Update ) ;
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
# if !defined(Q3_VM) && defined(FTEPLUGIN)
CHECKBUILTIN ( Cvar_GetNVFDG ) ;
# endif
2004-10-15 00:35:53 +00:00
2005-11-30 00:48:29 +00:00
//file system
2014-10-05 20:04:11 +00:00
# if !defined(Q3_VM) && defined(FTEPLUGIN)
CHECKBUILTIN ( VFS_Open ) ;
# endif
2005-11-30 00:48:29 +00:00
CHECKBUILTIN ( FS_Open ) ;
CHECKBUILTIN ( FS_Read ) ;
CHECKBUILTIN ( FS_Write ) ;
CHECKBUILTIN ( FS_Close ) ;
2016-07-12 00:40:13 +00:00
CHECKBUILTIN ( FS_Seek ) ;
CHECKBUILTIN ( FS_GetLen ) ;
2005-11-30 00:48:29 +00:00
2005-07-20 11:50:00 +00:00
//networking
CHECKBUILTIN ( Net_TCPConnect ) ;
CHECKBUILTIN ( Net_TCPListen ) ;
CHECKBUILTIN ( Net_Accept ) ;
CHECKBUILTIN ( Net_Recv ) ;
CHECKBUILTIN ( Net_Send ) ;
CHECKBUILTIN ( Net_Close ) ;
2016-07-12 00:40:13 +00:00
CHECKBUILTIN ( Net_SetTLSClient ) ;
2017-09-20 11:27:13 +00:00
CHECKBUILTIN ( Net_GetTLSBinding ) ;
2005-07-20 11:50:00 +00:00
//random things
2004-10-15 00:35:53 +00:00
CHECKBUILTIN ( CL_GetStats ) ;
2006-01-21 00:07:47 +00:00
CHECKBUILTIN ( GetPlayerInfo ) ;
2007-09-17 20:54:26 +00:00
CHECKBUILTIN ( LocalPlayerNumber ) ;
2015-04-21 04:12:00 +00:00
CHECKBUILTIN ( GetLocalPlayerNumbers ) ;
2015-12-28 17:41:39 +00:00
# ifdef FTEPLUGIN
2015-10-27 15:20:15 +00:00
CHECKBUILTIN ( GetLastInputFrame ) ;
2015-12-28 17:41:39 +00:00
# endif
2015-10-27 15:20:15 +00:00
CHECKBUILTIN ( GetTrackerOwnFrags ) ;
2007-09-17 20:54:26 +00:00
CHECKBUILTIN ( GetServerInfo ) ;
CHECKBUILTIN ( SetUserInfo ) ;
2004-10-15 00:35:53 +00:00
CHECKBUILTIN ( LocalSound ) ;
CHECKBUILTIN ( Menu_Control ) ;
CHECKBUILTIN ( Key_GetKeyCode ) ;
2007-10-05 10:50:13 +00:00
CHECKBUILTIN ( GetLocationName ) ;
2015-06-29 23:46:31 +00:00
CHECKBUILTIN ( GetTeamInfo ) ;
2015-10-27 15:20:15 +00:00
CHECKBUILTIN ( GetWeaponStats ) ;
2015-04-21 04:12:00 +00:00
CHECKBUILTIN ( GetNetworkInfo ) ;
2004-10-15 00:35:53 +00:00
2016-07-12 00:40:13 +00:00
# ifndef Q3_VM
CHECKBUILTIN ( PR_GetVMInstance ) ;
# endif
2005-07-20 11:50:00 +00:00
//drawing routines
2013-11-21 23:02:28 +00:00
CHECKBUILTIN ( Draw_LoadImageData ) ;
CHECKBUILTIN ( Draw_LoadImageShader ) ;
2004-10-15 00:35:53 +00:00
CHECKBUILTIN ( Draw_LoadImage ) ;
CHECKBUILTIN ( Draw_Image ) ;
2015-04-21 04:12:00 +00:00
CHECKBUILTIN ( Draw_ImageSize ) ;
2005-12-10 00:19:24 +00:00
CHECKBUILTIN ( Draw_Line ) ;
2004-10-15 00:35:53 +00:00
CHECKBUILTIN ( Draw_Fill ) ;
CHECKBUILTIN ( Draw_Character ) ;
2013-11-21 23:02:28 +00:00
CHECKBUILTIN ( Draw_String ) ;
2015-06-17 13:05:20 +00:00
CHECKBUILTIN ( Draw_CharacterH ) ;
CHECKBUILTIN ( Draw_StringH ) ;
2015-10-27 15:20:15 +00:00
CHECKBUILTIN ( Draw_StringWidth ) ;
2015-06-17 13:05:20 +00:00
CHECKBUILTIN ( Draw_Colourpa ) ;
2004-10-15 00:35:53 +00:00
CHECKBUILTIN ( Draw_Colourp ) ;
CHECKBUILTIN ( Draw_Colour3f ) ;
CHECKBUILTIN ( Draw_Colour4f ) ;
2005-11-27 01:12:16 +00:00
CHECKBUILTIN ( SCR_CenterPrint ) ;
2005-07-20 11:50:00 +00:00
2015-08-24 03:54:39 +00:00
CHECKBUILTIN ( Plug_GetPluginName ) ;
2005-12-15 18:52:03 +00:00
2005-07-20 11:50:00 +00:00
//sub consoles (optional)
CHECKBUILTIN ( Con_SubPrint ) ;
CHECKBUILTIN ( Con_RenameSub ) ;
2005-12-16 18:08:40 +00:00
CHECKBUILTIN ( Con_IsActive ) ;
CHECKBUILTIN ( Con_SetActive ) ;
CHECKBUILTIN ( Con_Destroy ) ;
CHECKBUILTIN ( Con_NameForNum ) ;
2015-04-21 04:12:00 +00:00
CHECKBUILTIN ( Con_GetConsoleFloat ) ;
CHECKBUILTIN ( Con_SetConsoleFloat ) ;
CHECKBUILTIN ( Con_GetConsoleString ) ;
CHECKBUILTIN ( Con_SetConsoleString ) ;
2017-10-12 12:02:25 +00:00
CHECKBUILTIN ( Con_POpen ) ;
2019-06-21 03:59:46 +00:00
CHECKBUILTIN ( MapLog_Query ) ;
2004-10-15 00:35:53 +00:00
}
# ifndef Q3_VM
2018-07-22 11:49:37 +00:00
NATIVEEXPORT void QDECL dllEntry ( qintptr_t ( QDECL * funcptr ) ( qintptr_t , . . . ) )
2005-05-17 22:05:45 +00:00
{
2005-06-15 15:40:10 +00:00
plugin_syscall = funcptr ;
2004-10-15 00:35:53 +00:00
}
# endif
2015-04-21 04:12:00 +00:00
vmvideo_t pvid ;
2018-10-11 10:31:23 +00:00
static qintptr_t QDECL Plug_UpdateVideo ( qintptr_t * args )
2004-10-15 00:35:53 +00:00
{
2015-04-21 04:12:00 +00:00
pvid . width = args [ 0 ] ;
pvid . height = args [ 1 ] ;
2004-10-15 00:35:53 +00:00
return true ;
}
2018-10-11 10:31:23 +00:00
static qintptr_t QDECL Plug_InitAPI ( qintptr_t * args )
2004-10-15 00:35:53 +00:00
{
# ifdef Q3_VM
Plug_GetEngineFunction = ( void * ) args [ 0 ] ;
# else
BUILTIN_Plug_GetEngineFunction = args [ 0 ] ;
# endif
Plug_InitStandardBuiltins ( ) ;
Plug_Export ( " UpdateVideo " , Plug_UpdateVideo ) ;
return Plug_Init ( args ) ;
}
2012-10-08 05:29:52 +00:00
qboolean Plug_Export ( const char * name , export_t func )
2004-10-15 00:35:53 +00:00
{
2018-08-04 19:00:19 +00:00
size_t i ;
2004-10-15 00:35:53 +00:00
for ( i = 0 ; i < sizeof ( exports ) / sizeof ( exports [ 0 ] ) ; i + + )
{
if ( ! exports [ i ] . name )
{
exports [ i ] . name = name ;
exports [ i ] . func = func ;
2018-08-04 19:00:19 +00:00
return pPlug_ExportToEngine ( name , i ) ? qtrue : qfalse ;
2004-10-15 00:35:53 +00:00
}
}
2013-05-03 04:29:36 +00:00
pSys_Error ( " Plugin exports too many functions " ) ;
2018-08-04 19:00:19 +00:00
return qfalse ;
2004-10-15 00:35:53 +00:00
}
exports_t exports [ sizeof ( exports ) / sizeof ( exports [ 0 ] ) ] = {
{ " Plug_Init " , Plug_InitAPI } ,
} ;
2005-07-20 11:50:00 +00:00