2005-07-20 11:50:00 +00:00
# ifndef __PLUGIN_H__
# define __PLUGIN_H__
2005-12-01 01:16:55 +00:00
2013-05-03 04:29:36 +00:00
# ifdef FTEPLUGIN
# include "quakedef.h"
2014-02-07 08:38:40 +00:00
# define QPREFIX
# endif
# if !defined(NOQPREFIX) && !defined(QPREFIX)
# define QPREFIX
2013-05-03 04:29:36 +00:00
# endif
2004-10-15 00:35:53 +00:00
# ifdef Q3_VM
2012-10-08 05:29:52 +00:00
typedef int qintptr_t ;
typedef unsigned int quintptr_t ;
2013-03-31 04:21:08 +00:00
typedef unsigned int size_t ;
typedef signed int ssize_t ;
2005-12-01 01:16:55 +00:00
# define TESTBI 1
# ifdef TESTBI
# define EBUILTIN(t, n, args) extern t (*n) args
# define BUILTINR(t, n, args) t (*n) args
# define BUILTIN(t, n, args) t (*n) args
# define BUILTINISVALID(n) (n!=NULL && (funcptr_t)n != (funcptr_t)&BadBuiltin)
# define CHECKBUILTIN(n) n = (funcptr_t)Plug_GetEngineFunction(#n);if (n==NULL) {n = (funcptr_t)&BadBuiltin;Con_Print("Warning: builtin "#n" is not supported by the engine\n");}
# else
2004-10-15 00:35:53 +00:00
//qvms just call the return value, and the engine works out which one it called.
2005-12-01 01:16:55 +00:00
# define EBUILTIN(t, n, args) extern t (*n) args
# define BUILTINR(t, n, args) t (*n) args
# define BUILTIN(t, n, args) t (*n) args
# define CHECKBUILTIN(n) n = (funcptr_t)Plug_GetEngineFunction(#n);
2005-12-15 18:52:03 +00:00
# define BUILTINISVALID(n) (n!=NULL)
2005-12-01 01:16:55 +00:00
# endif
2004-10-15 00:35:53 +00:00
# define double float //all floats are 32bit, qvm stuff
typedef char * va_list ;
# define va_start(va,f) (va = (char *)&f + sizeof(int))
# define va_arg(va, type) (*(type *)((va += sizeof(int)) - sizeof(int)))
# define va_end(va) (va = NULL)
# define NULL (void*)0
2005-11-27 01:12:16 +00:00
void * malloc ( int size ) ;
void free ( void * mem ) ;
char * strstr ( char * str , const char * sub ) ;
void strlcpy ( char * d , const char * s , int n ) ;
2005-11-27 03:18:43 +00:00
char * strchr ( char * str , char sub ) ;
2005-11-27 01:12:16 +00:00
2005-11-30 01:02:10 +00:00
float atof ( char * str ) ;
int atoi ( char * str ) ;
2005-12-06 15:40:52 +00:00
# define strcasecmp stricmp
2013-09-08 19:01:12 +00:00
# define strncasecmp stricmp
2005-12-06 15:40:52 +00:00
2005-12-01 01:16:55 +00:00
void BadBuiltin ( void ) ;
2004-10-15 00:35:53 +00:00
# else
2013-09-08 19:01:12 +00:00
# ifdef _WIN32
2018-11-19 06:37:25 +00:00
# ifndef strcasecmp
# define strcasecmp stricmp
# define strncasecmp strnicmp
# endif
2013-09-08 19:01:12 +00:00
# else
2018-11-19 06:37:25 +00:00
# define stricmp strcasecmp
# define strnicmp strncasecmp
2013-09-08 19:01:12 +00:00
# endif
2005-12-06 15:40:52 +00:00
2004-10-15 00:35:53 +00:00
# include <string.h>
# include <stdlib.h>
# include <stdarg.h>
2013-05-03 04:29:36 +00:00
# include <math.h>
2012-10-07 18:26:22 +00:00
2013-05-03 04:29:36 +00:00
# ifndef _VM_H
2016-07-12 00:40:13 +00:00
# if __STDC_VERSION__ >= 199901L || defined(__GNUC__)
2014-06-24 03:04:30 +00:00
//C99 has a stdint header which hopefully contains an intptr_t
//its optional... but if its not in there then its unlikely you'll actually be able to get the engine to a stage where it *can* load anything
# include <stdint.h>
# define qintptr_t intptr_t
# define quintptr_t uintptr_t
# else
# ifdef _WIN64
typedef long long qintptr_t ;
typedef unsigned long long quintptr_t ;
# else
2016-08-25 00:12:14 +00:00
# if !defined(_MSC_VER) || _MSC_VER < 1300
2014-06-24 03:04:30 +00:00
# define __w64
# endif
typedef long __w64 qintptr_t ;
typedef unsigned long __w64 quintptr_t ;
# endif
# endif
2013-05-03 04:29:36 +00:00
# endif
2012-10-08 05:29:52 +00:00
2018-07-22 11:49:37 +00:00
# ifndef NATIVEEXPORT
# ifdef _WIN32
# define NATIVEEXPORTPROTO __declspec(dllexport)
# define NATIVEEXPORT NATIVEEXPORTPROTO
# else
# define NATIVEEXPORTPROTO
# define NATIVEEXPORT __attribute__((visibility("default")))
# endif
2012-10-08 05:29:52 +00:00
# endif
2014-02-07 08:38:40 +00:00
# ifndef QPREFIX
2013-05-03 04:29:36 +00:00
# define pPlug_GetEngineFunction Plug_GetEngineFunction
# define pCon_Print Con_Print
# define pCvar_GetFloat Cvar_GetFloat
# define pSys_Error Sys_Error
# define pPlug_ExportToEngine Plug_ExportToEngine
# endif
2012-10-07 18:26:22 +00:00
# ifdef __cplusplus
extern " C " {
# endif
2004-10-15 00:35:53 +00:00
//DLLs need a wrapper to add the extra parameter and call a boring function.
2005-12-01 01:16:55 +00:00
# define TEST
2014-02-07 08:38:40 +00:00
# ifdef QPREFIX
2013-05-03 04:29:36 +00:00
# define EBUILTIN(t, n, args) extern qintptr_t BUILTIN_##n; t p##n args
# define BUILTINR(t, n, args) qintptr_t BUILTIN_##n; t p##n args {qintptr_t res; if (!BUILTINISVALID(n))pSys_Error("Builtin "#n" is not valid\n");res = plugin_syscall(BUILTIN_##n ARGNAMES); return *(t*)&res;}
# define BUILTIN(t, n, args) qintptr_t BUILTIN_##n; t p##n args {if (!BUILTINISVALID(n))pSys_Error("Builtin "#n" is not valid\n");plugin_syscall(BUILTIN_##n ARGNAMES);}
# elif defined(TEST)
# define EBUILTIN(t, n, args) extern qintptr_t BUILTIN_##n; t n args
2012-10-08 05:29:52 +00:00
# define BUILTINR(t, n, args) qintptr_t BUILTIN_##n; t n args {qintptr_t res; if (!BUILTINISVALID(n))Sys_Error("Builtin "#n" is not valid\n");res = plugin_syscall(BUILTIN_##n ARGNAMES); return *(t*)&res;}
# define BUILTIN(t, n, args) qintptr_t BUILTIN_##n; t n args {if (!BUILTINISVALID(n))Sys_Error("Builtin "#n" is not valid\n");plugin_syscall(BUILTIN_##n ARGNAMES);}
2005-12-01 01:16:55 +00:00
# else
2013-05-03 04:29:36 +00:00
# define EBUILTIN(t, n, args) extern qintptr_t BUILTIN_##n; t n args
2012-10-08 05:29:52 +00:00
# define BUILTINR(t, n, args) qintptr_t BUILTIN_##n; t n args {qintptr_t res = plugin_syscall(BUILTIN_##n ARGNAMES); return *(t*)&res;}
# define BUILTIN(t, n, args) qintptr_t BUILTIN_##n; t n args {plugin_syscall(BUILTIN_##n ARGNAMES);}
2005-12-01 01:16:55 +00:00
# endif
2016-07-12 00:40:13 +00:00
# define CHECKBUILTIN(n) ((BUILTIN_##n = (qintptr_t)pPlug_GetEngineFunction(#n)))
2005-12-15 18:52:03 +00:00
# define BUILTINISVALID(n) (BUILTIN_##n != 0)
2013-05-03 04:29:36 +00:00
# ifndef QDECL
2004-10-15 00:35:53 +00:00
# ifdef _WIN32
# define QDECL __cdecl
# else
# define QDECL
# endif
2013-05-03 04:29:36 +00:00
# endif
2019-02-16 19:09:07 +00:00
# ifndef LIKEPRINTF
# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
# define LIKEPRINTF(x) __attribute__((format(printf,x,x+1)))
# else
# define LIKEPRINTF(x)
# endif
# endif
2016-07-12 00:40:13 +00:00
extern qintptr_t ( QDECL * plugin_syscall ) ( qintptr_t arg , . . . ) ;
2004-10-15 00:35:53 +00:00
2017-10-12 12:02:25 +00:00
void Q_strlncpy ( char * d , const char * s , int sizeofd , int lenofs ) ;
2013-05-11 14:02:55 +00:00
void Q_strlcpy ( char * d , const char * s , int n ) ;
2013-06-23 02:33:52 +00:00
void Q_strlcat ( char * d , const char * s , int n ) ;
2019-02-16 19:09:07 +00:00
int Q_snprintf ( char * buffer , size_t maxlen , const char * format , . . . ) LIKEPRINTF ( 3 ) ;
2013-05-11 14:02:55 +00:00
int Q_vsnprintf ( char * buffer , size_t maxlen , const char * format , va_list vargs ) ;
2005-11-27 01:12:16 +00:00
2004-10-15 00:35:53 +00:00
# endif
2012-10-08 05:29:52 +00:00
# ifndef NATIVEEXPORT
2015-02-02 08:01:53 +00:00
# define NATIVEEXPORT QDECL
2012-10-08 05:29:52 +00:00
# endif
2013-05-03 04:29:36 +00:00
2013-05-04 10:40:05 +00:00
# ifdef FTEPLUGIN
# define qfalse false
# define qtrue true
# else
2012-10-07 18:26:22 +00:00
# ifdef __cplusplus
typedef enum { qfalse , qtrue } qboolean ;
# else
typedef enum { qfalse , qtrue } qboolean ;
# define false qfalse
# define true qtrue
# endif
2005-11-27 01:12:16 +00:00
typedef float vec3_t [ 3 ] ;
2013-05-03 04:29:36 +00:00
typedef unsigned char qbyte ;
# endif
2013-05-04 10:40:05 +00:00
typedef int qhandle_t ;
2005-12-01 01:16:55 +00:00
typedef void * funcptr_t ;
2004-10-15 00:35:53 +00:00
2006-01-21 00:07:47 +00:00
# define PLUGMAX_SCOREBOARDNAME 64
typedef struct {
int topcolour ;
int bottomcolour ;
int frags ;
char name [ PLUGMAX_SCOREBOARDNAME ] ;
int ping ;
int pl ;
int starttime ;
int userid ;
int spectator ;
2016-07-12 00:40:13 +00:00
char userinfo [ 2048 ] ;
char team [ 64 ] ;
2006-01-21 00:07:47 +00:00
} plugclientinfo_t ;
2004-10-15 00:35:53 +00:00
//Basic builtins:
2012-10-08 05:29:52 +00:00
EBUILTIN ( funcptr_t , Plug_GetEngineFunction , ( const char * funcname ) ) ; //set up in vmMain, use this to get all other builtins
2015-02-02 08:01:53 +00:00
# ifdef FTEENGINE
# else
2012-04-23 05:07:40 +00:00
# ifndef Q3_VM
2012-10-08 05:29:52 +00:00
EBUILTIN ( qboolean , Plug_ExportNative , ( const char * funcname , void * func ) ) ; //set up in vmMain, use this to get all other builtins
2016-07-12 00:40:13 +00:00
EBUILTIN ( void * , Plug_GetNativePointer , ( const char * funcname ) ) ;
2012-04-23 05:07:40 +00:00
# endif
2012-10-08 05:29:52 +00:00
EBUILTIN ( void , Con_Print , ( const char * text ) ) ; //on to main console.
2005-12-16 18:08:40 +00:00
2018-03-04 14:41:16 +00:00
EBUILTIN ( qhandle_t , Con_POpen , ( const char * conname , quintptr_t flags ) ) ;
2013-03-31 04:21:08 +00:00
EBUILTIN ( void , Con_SubPrint , ( const char * subname , const char * text ) ) ; //on to sub console.
2015-04-21 04:12:00 +00:00
EBUILTIN ( void , Con_RenameSub , ( const char * oldname , const char * newname ) ) ; //rename a console.
EBUILTIN ( int , Con_IsActive , ( const char * conname ) ) ;
EBUILTIN ( void , Con_SetActive , ( const char * conname ) ) ;
EBUILTIN ( void , Con_Destroy , ( const char * conname ) ) ;
2018-03-04 14:41:16 +00:00
EBUILTIN ( void , Con_NameForNum , ( qintptr_t connum , char * conname , quintptr_t connamelen ) ) ;
2015-04-21 04:12:00 +00:00
EBUILTIN ( float , Con_GetConsoleFloat , ( const char * conname , const char * attribname ) ) ;
EBUILTIN ( void , Con_SetConsoleFloat , ( const char * conname , const char * attribname , float newvalue ) ) ;
2018-03-04 14:41:16 +00:00
EBUILTIN ( int , Con_GetConsoleString , ( const char * conname , const char * attribname , const char * value , quintptr_t valuesize ) ) ;
2015-04-21 04:12:00 +00:00
EBUILTIN ( void , Con_SetConsoleString , ( const char * conname , const char * attribname , const char * newvalue ) ) ;
2005-12-16 18:08:40 +00:00
2015-06-12 14:44:50 +00:00
EBUILTIN ( void , Sys_Error , ( const char * message ) ) ; //abort the entire engine.
2018-10-11 10:31:23 +00:00
EBUILTIN ( quintptr_t , Sys_Milliseconds , ( void ) ) ;
2004-10-15 00:35:53 +00:00
2018-10-11 10:31:23 +00:00
EBUILTIN ( int , Cmd_AddCommand , ( const char * buffer ) ) ; //Registers a console command.
2004-10-15 00:35:53 +00:00
EBUILTIN ( void , Cmd_Args , ( char * buffer , int bufsize ) ) ; //abort the entire engine.
EBUILTIN ( void , Cmd_Argv , ( int argnum , char * buffer , int bufsize ) ) ; //abort the entire engine.
2005-11-27 01:12:16 +00:00
EBUILTIN ( int , Cmd_Argc , ( void ) ) ; //abort the entire engine.
2015-06-12 14:44:50 +00:00
EBUILTIN ( void , Cmd_AddText , ( const char * text , qboolean insert ) ) ;
2018-10-11 10:31:23 +00:00
EBUILTIN ( void , Cmd_TokenizeString , ( const char * msg ) ) ; //tokenize a string.
2015-06-12 14:44:50 +00:00
2015-08-24 03:54:39 +00:00
EBUILTIN ( void , Cvar_SetString , ( const char * name , const char * value ) ) ;
2015-06-12 14:44:50 +00:00
EBUILTIN ( void , Cvar_SetFloat , ( const char * name , float value ) ) ;
2018-03-04 14:41:16 +00:00
EBUILTIN ( qboolean , Cvar_GetString , ( const char * name , char * retstring , quintptr_t sizeofretstring ) ) ;
2015-06-12 14:44:50 +00:00
EBUILTIN ( float , Cvar_GetFloat , ( const char * name ) ) ;
EBUILTIN ( qhandle_t , Cvar_Register , ( const char * name , const char * defaultval , int flags , const char * grouphint ) ) ;
2005-11-27 01:12:16 +00:00
EBUILTIN ( 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.
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
# ifdef FTEPLUGIN
EBUILTIN ( cvar_t * , Cvar_GetNVFDG , ( const char * name , const char * defaultval , unsigned int flags , const char * description , const char * groupname ) ) ;
# endif
2004-10-15 00:35:53 +00:00
2015-08-24 03:54:39 +00:00
EBUILTIN ( void , Plug_GetPluginName , ( int plugnum , char * buffer , int bufsize ) ) ;
2015-06-12 14:44:50 +00:00
EBUILTIN ( void , LocalSound , ( const char * soundname ) ) ;
2013-03-31 04:21:08 +00:00
EBUILTIN ( int , CL_GetStats , ( int pnum , unsigned int * stats , int maxstats ) ) ;
2006-01-21 00:07:47 +00:00
EBUILTIN ( int , GetPlayerInfo , ( int pnum , plugclientinfo_t * info ) ) ;
2009-04-19 01:46:52 +00:00
2015-04-21 04:12:00 +00:00
EBUILTIN ( int , LocalPlayerNumber , ( void ) ) ; //deprecated
EBUILTIN ( int , GetLocalPlayerNumbers , ( int firstseat , int numseats , int * playernums , int * spectracks ) ) ;
2007-09-17 20:54:26 +00:00
EBUILTIN ( void , GetServerInfo , ( char * info , int infolen ) ) ;
2015-06-12 14:44:50 +00:00
EBUILTIN ( void , SetUserInfo , ( const char * key , const char * value ) ) ;
EBUILTIN ( void , GetLocationName , ( const float * pos , char * buffer , int bufferlen ) ) ;
2015-11-18 07:37:39 +00:00
# ifdef FTEPLUGIN
2015-10-27 15:20:15 +00:00
EBUILTIN ( int , GetLastInputFrame , ( int seat , usercmd_t * playercmd ) ) ;
2015-11-18 07:37:39 +00:00
# endif
2015-10-27 15:20:15 +00:00
EBUILTIN ( float , GetTrackerOwnFrags , ( int seat , char * text , size_t textsize ) ) ;
2015-06-29 23:46:31 +00:00
2016-07-12 00:40:13 +00:00
# ifndef Q3_VM
struct pubprogfuncs_s ;
EBUILTIN ( struct pubprogfuncs_s * , PR_GetVMInstance , ( int vmid /*0=ss,1=cs,2=m*/ ) ) ;
struct modplugfuncs_s ;
EBUILTIN ( struct modplugfuncs_s * , Mod_GetPluginModelFuncs , ( int version ) ) ;
# ifdef MULTITHREAD
struct threading_s ;
EBUILTIN ( struct threading_s * , Sys_GetThreadingFuncs , ( int threadingsize ) ) ;
# endif
# endif
2015-06-29 23:46:31 +00:00
typedef struct
{
unsigned int client ;
unsigned int items ;
float armor ;
float health ;
vec3_t org ;
char nick [ 16 ] ;
} teamplayerinfo_t ;
EBUILTIN ( int , GetTeamInfo , ( teamplayerinfo_t * clients , unsigned int maxclients , int showenemies , int showself ) ) ;
2015-10-27 15:20:15 +00:00
struct wstats_s ;
EBUILTIN ( int , GetWeaponStats , ( int player , struct wstats_s * result , unsigned int maxresults ) ) ;
2015-04-21 04:12:00 +00:00
typedef struct {
int seats ;
struct
{
2015-06-12 14:44:50 +00:00
float s_avg ;
float s_mn ;
float s_mx ;
float ms_stddev ; //calculated in milliseconds for more sane numbers
float fr_avg ;
int fr_mn ;
int fr_mx ;
2015-04-21 04:12:00 +00:00
} ping ;
2015-06-12 14:44:50 +00:00
struct
{ //decimals
float dropped ;
float choked ;
float invalid ;
} loss ;
2015-04-21 04:12:00 +00:00
float mlatency ;
float mrate ;
float vlatency ;
float vrate ;
vec3_t speed ; //player speed
struct
{
float in_pps ;
float in_bps ;
float out_pps ;
float out_bps ;
} clrate ;
struct
{
float in_pps ;
float in_bps ;
float out_pps ;
float out_bps ;
} svrate ;
2015-06-12 14:44:50 +00:00
int capturing ; //avi capturing
2015-04-21 04:12:00 +00:00
} vmnetinfo_t ;
EBUILTIN ( int , GetNetworkInfo , ( vmnetinfo_t * ni , unsigned int sizeofni ) ) ;
2004-10-15 00:35:53 +00:00
EBUILTIN ( void , Menu_Control , ( int mnum ) ) ;
2005-07-20 11:50:00 +00:00
# define MENU_CLEAR 0
# define MENU_GRAB 1
2016-07-12 00:40:13 +00:00
EBUILTIN ( int , Key_GetKeyCode , ( const char * keyname ) ) ;
2004-10-15 00:35:53 +00:00
2015-04-21 04:12:00 +00:00
EBUILTIN ( qhandle_t , Draw_LoadImageData , ( const char * name , const char * mime , const void * data , unsigned int datasize ) ) ; //load/replace a named texture
EBUILTIN ( qhandle_t , Draw_LoadImageShader , ( const char * name , const char * defaultshader ) ) ; //loads a shader.
EBUILTIN ( qhandle_t , Draw_LoadImage , ( const char * name , qboolean iswadimage ) ) ; //wad image is ONLY for loading out of q1 gfx.wad. loads a shader.
2006-02-11 13:48:31 +00:00
EBUILTIN ( int , Draw_Image , ( float x , float y , float w , float h , float s1 , float t1 , float s2 , float t2 , qhandle_t image ) ) ;
2015-04-21 04:12:00 +00:00
EBUILTIN ( int , Draw_ImageSize , ( qhandle_t image , float * x , float * y ) ) ;
2006-01-13 06:11:47 +00:00
EBUILTIN ( void , Draw_Fill , ( float x , float y , float w , float h ) ) ;
2005-12-10 00:19:24 +00:00
EBUILTIN ( void , Draw_Line , ( float x1 , float y1 , float x2 , float y2 ) ) ;
2013-04-14 09:58:23 +00:00
EBUILTIN ( void , Draw_Character , ( int x , int y , unsigned int character ) ) ;
2015-04-21 04:12:00 +00:00
EBUILTIN ( void , Draw_String , ( float x , float y , const char * string ) ) ;
2015-06-17 13:05:20 +00:00
EBUILTIN ( void , Draw_CharacterH , ( float x , float y , float h , unsigned int flags , unsigned int character ) ) ;
2015-10-27 15:20:15 +00:00
EBUILTIN ( void , Draw_StringH , ( float x , float y , float h , unsigned int flags , const char * string ) ) ; //returns the vpixel width of the (coloured) string, in the current (variable-width) font.
EBUILTIN ( float , Draw_StringWidth , ( float h , unsigned int flags , const char * string ) ) ;
2015-06-17 13:05:20 +00:00
EBUILTIN ( void , Draw_Colourpa , ( int palcol , float a ) ) ;
2004-10-15 00:35:53 +00:00
EBUILTIN ( void , Draw_Colourp , ( int palcol ) ) ;
EBUILTIN ( void , Draw_Colour3f , ( float r , float g , float b ) ) ;
EBUILTIN ( void , Draw_Colour4f , ( float r , float g , float b , float a ) ) ;
2016-07-12 00:40:13 +00:00
EBUILTIN ( void , SCR_CenterPrint , ( const char * s ) ) ;
2004-10-15 00:35:53 +00:00
2013-06-23 18:43:59 +00:00
EBUILTIN ( void , S_RawAudio , ( int sourceid , void * data , int speed , int samples , int channels , int width , float volume ) ) ;
2013-05-03 04:29:36 +00:00
2009-04-19 01:46:52 +00:00
EBUILTIN ( int , ReadInputBuffer , ( void * inputbuffer , int buffersize ) ) ;
EBUILTIN ( int , UpdateInputBuffer , ( void * inputbuffer , int bytes ) ) ;
2014-10-05 20:04:11 +00:00
# if !defined(Q3_VM) && defined(FTEPLUGIN)
2016-07-12 00:40:13 +00:00
EBUILTIN ( 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
EBUILTIN ( qboolean , FS_NativePath , ( const char * name , enum fs_relative relativeto , char * out , int outlen ) ) ;
2014-10-05 20:04:11 +00:00
# endif
2016-07-12 00:40:13 +00:00
EBUILTIN ( int , FS_Open , ( const char * name , qhandle_t * handle , int mode ) ) ;
2005-12-06 15:40:52 +00:00
EBUILTIN ( void , FS_Close , ( qhandle_t handle ) ) ;
EBUILTIN ( int , FS_Write , ( qhandle_t handle , void * data , int len ) ) ;
EBUILTIN ( int , FS_Read , ( qhandle_t handle , void * data , int len ) ) ;
2013-05-03 04:29:36 +00:00
EBUILTIN ( int , FS_Seek , ( qhandle_t handle , unsigned int offsetlow , unsigned int offsethigh ) ) ;
2016-07-12 00:40:13 +00:00
EBUILTIN ( qboolean , FS_GetLen , ( qhandle_t handle , unsigned int * sizelow , unsigned int * sizehigh ) ) ;
2005-12-06 15:40:52 +00:00
EBUILTIN ( qhandle_t , Net_TCPConnect , ( char * ip , int port ) ) ;
EBUILTIN ( qhandle_t , Net_TCPListen , ( char * ip , int port , int maxcount ) ) ;
EBUILTIN ( qhandle_t , Net_Accept , ( qhandle_t socket , char * address , int addresssize ) ) ;
EBUILTIN ( int , Net_Recv , ( qhandle_t socket , void * buffer , int len ) ) ;
EBUILTIN ( int , Net_Send , ( qhandle_t socket , void * buffer , int len ) ) ;
EBUILTIN ( void , Net_Close , ( qhandle_t socket ) ) ;
2016-07-12 00:40:13 +00:00
EBUILTIN ( int , Net_SetTLSClient , ( qhandle_t sock , const char * certhostname ) ) ;
2017-09-20 11:27:13 +00:00
EBUILTIN ( int , Net_GetTLSBinding , ( qhandle_t sock , char * outdata , int * datalen ) ) ;
2019-02-16 19:09:07 +00:00
# define N_WOULDBLOCK -1
# define N_FATALERROR -2
2005-11-27 01:12:16 +00:00
# define NET_CLIENTPORT -1
# define NET_SERVERPORT -2
2005-07-20 11:50:00 +00:00
# ifdef Q3_VM
EBUILTIN ( void , memcpy , ( void * , void * , int len ) ) ;
2005-12-01 01:16:55 +00:00
EBUILTIN ( void , memmove , ( void * , void * , int len ) ) ;
2005-07-20 11:50:00 +00:00
EBUILTIN ( void , memset , ( void * , int , int len ) ) ;
2005-12-06 15:40:52 +00:00
EBUILTIN ( float , sqrt , ( float f ) ) ;
2005-12-10 00:19:24 +00:00
EBUILTIN ( float , cos , ( float f ) ) ;
EBUILTIN ( float , sin , ( float f ) ) ;
2005-07-20 11:50:00 +00:00
# endif
2015-02-02 08:01:53 +00:00
# endif
2005-07-20 11:50:00 +00:00
2015-02-02 08:01:53 +00:00
typedef qintptr_t ( QDECL * export_t ) ( qintptr_t * args ) ;
2013-11-29 14:36:47 +00:00
char * va ( const char * format , . . . ) ;
2012-10-08 05:29:52 +00:00
qintptr_t Plug_Init ( qintptr_t * args ) ;
qboolean Plug_Export ( const char * name , export_t func ) ;
void Con_Printf ( const char * format , . . . ) ;
2012-11-27 03:23:19 +00:00
void Con_DPrintf ( const char * format , . . . ) ; //not a particuarly efficient implementation, so beware.
2012-10-08 05:29:52 +00:00
void Sys_Errorf ( const char * format , . . . ) ;
2015-02-02 08:01:53 +00:00
void QDECL Q_strncpyz ( char * d , const char * s , int n ) ;
2004-10-15 00:35:53 +00:00
2018-10-11 10:31:23 +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*/ ) ;
NATIVEEXPORT void QDECL dllEntry ( qintptr_t ( QDECL * funcptr ) ( qintptr_t , . . . ) ) ;
2009-04-19 01:46:52 +00:00
# define PLUG_SHARED_BEGIN(t,p,b) \
{ \
t * p ; \
char inputbuffer [ 8192 ] ; \
* ( b ) = ReadInputBuffer ( inputbuffer , sizeof ( inputbuffer ) ) ; \
if ( * ( b ) ) \
p = ( t * ) inputbuffer ; \
else \
p = NULL ;
# define PLUG_SHARED_END(p,b) UpdateInputBuffer(inputbuffer, b);}
2007-09-21 11:19:41 +00:00
//
// qvm_api.c
//
2013-05-03 04:29:36 +00:00
//int vsnprintf(char *buffer, size_t maxlen, const char *format, va_list vargs);
2004-10-15 00:35:53 +00:00
typedef struct {
char * name ;
char string [ 256 ] ;
char * group ;
int flags ;
float value ;
qhandle_t handle ;
int modificationcount ;
} vmcvar_t ;
typedef struct {
int width ;
int height ;
} vmvideo_t ;
2015-04-21 04:12:00 +00:00
extern vmvideo_t pvid ;
2004-10-15 00:35:53 +00:00
# define VMCvar_SetString(c,v) \
do { \
strcpy ( c - > string , v ) ; \
c - > value = ( float ) atof ( v ) ; \
Cvar_SetString ( c - > name , c - > string ) ; \
} while ( 0 )
# define VMCvar_SetFloat(c,v) \
do { \
snprintf ( c - > string , sizeof ( c - > string ) , " %f " , v ) ; \
c - > value = ( float ) ( v ) ; \
Cvar_SetFloat ( c - > name , c - > value ) ; \
} while ( 0 ) \
2013-05-03 04:29:36 +00:00
# ifndef MAX_INFO_KEY
2004-10-15 00:35:53 +00:00
# define MAX_INFO_KEY 64
2013-05-03 04:29:36 +00:00
# endif
2016-07-12 00:40:13 +00:00
char * Plug_Info_ValueForKey ( const char * s , const char * key , char * out , size_t outsize ) ;
2013-05-03 04:29:36 +00:00
void Info_RemoveKey ( char * s , const char * key ) ;
2004-10-15 00:35:53 +00:00
void Info_RemovePrefixedKeys ( char * start , char prefix ) ;
void Info_RemoveNonStarKeys ( char * start ) ;
2013-05-03 04:29:36 +00:00
void Info_SetValueForKey ( char * s , const char * key , const char * value , int maxsize ) ;
void Info_SetValueForStarKey ( char * s , const char * key , const char * value , int maxsize ) ;
2004-10-15 00:35:53 +00:00
2012-10-07 18:26:22 +00:00
# ifdef __cplusplus
}
# endif
2005-07-20 11:50:00 +00:00
# endif