stripped support for qvm-based plugins. rewrote native plugins to use a more efficient interface.
merged engine menus, native menus, game menus, plugin menus into a single layered menu interface, simplifying all the special-case input. engine confirmation prompts can now show regardless of underlaying menus, including above the console. skeletal formats can now provide their own way to build bones, for variable per-bone keyframes/interpolation methods/etc (used by gltf2). updated various plugins for the new api. removed qvm makefiles/scripts. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5530 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
6f00bc8e8a
commit
d561772bb0
116 changed files with 4885 additions and 6715 deletions
467
plugins/plugin.h
467
plugins/plugin.h
|
@ -1,65 +1,35 @@
|
|||
#ifndef __PLUGIN_H__
|
||||
#define __PLUGIN_H__
|
||||
|
||||
#ifdef FTEPLUGIN
|
||||
#include "quakedef.h"
|
||||
#define QPREFIX
|
||||
#endif
|
||||
|
||||
#if !defined(NOQPREFIX) && !defined(QPREFIX)
|
||||
#define QPREFIX
|
||||
#endif
|
||||
|
||||
#ifdef Q3_VM
|
||||
|
||||
typedef int qintptr_t;
|
||||
typedef unsigned int quintptr_t;
|
||||
|
||||
typedef unsigned int size_t;
|
||||
typedef signed int ssize_t;
|
||||
|
||||
#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");}
|
||||
#ifdef FTEENGINE
|
||||
//included from fte itself, to borrow typedefs
|
||||
#elif defined(FTEPLUGIN)
|
||||
//plugin that needs fte internals
|
||||
#include "quakedef.h"
|
||||
#else
|
||||
//moderately generic plugin
|
||||
#ifdef __cplusplus
|
||||
typedef enum {qfalse, qtrue} qboolean;
|
||||
#else
|
||||
typedef enum {qfalse, qtrue} qboolean;
|
||||
#define false qfalse
|
||||
#define true qtrue
|
||||
#endif
|
||||
typedef float vec3_t[3];
|
||||
typedef unsigned char qbyte;
|
||||
|
||||
//qvms just call the return value, and the engine works out which one it called.
|
||||
# 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);
|
||||
# define BUILTINISVALID(n) (n!=NULL)
|
||||
#include <stdint.h>
|
||||
#define quint64_t uint64_t
|
||||
typedef quint64_t qofs_t;
|
||||
|
||||
typedef struct cvar_s cvar_t;
|
||||
typedef struct usercmd_s usercmd_t;
|
||||
typedef struct vfsfile_s vfsfile_t;
|
||||
typedef struct netadr_s netadr_t;
|
||||
enum fs_relative;
|
||||
struct searchpathfuncs_s;
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
|
||||
void *malloc(int size);
|
||||
void free(void *mem);
|
||||
char *strstr(char *str, const char *sub);
|
||||
void strlcpy(char *d, const char *s, int n);
|
||||
char *strchr(char *str, char sub);
|
||||
|
||||
float atof(char *str);
|
||||
int atoi(char *str);
|
||||
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp stricmp
|
||||
|
||||
void BadBuiltin(void);
|
||||
|
||||
#else
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef strcasecmp
|
||||
# define strcasecmp stricmp
|
||||
|
@ -107,36 +77,11 @@ void BadBuiltin(void);
|
|||
#endif
|
||||
|
||||
|
||||
#ifndef QPREFIX
|
||||
#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
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//DLLs need a wrapper to add the extra parameter and call a boring function.
|
||||
#define TEST
|
||||
#ifdef QPREFIX
|
||||
#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
|
||||
#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);}
|
||||
#else
|
||||
#define EBUILTIN(t, n, args) extern qintptr_t BUILTIN_##n; t n args
|
||||
#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);}
|
||||
#endif
|
||||
#define CHECKBUILTIN(n) ((BUILTIN_##n = (qintptr_t)pPlug_GetEngineFunction(#n)))
|
||||
#define BUILTINISVALID(n) (BUILTIN_##n != 0)
|
||||
#ifndef QDECL
|
||||
#ifdef _WIN32
|
||||
#define QDECL __cdecl
|
||||
|
@ -153,32 +98,10 @@ extern "C" {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
extern qintptr_t (QDECL *plugin_syscall)( qintptr_t arg, ... );
|
||||
|
||||
void Q_strlncpy(char *d, const char *s, int sizeofd, int lenofs);
|
||||
void Q_strlcpy(char *d, const char *s, int n);
|
||||
void Q_strlcat(char *d, const char *s, int n);
|
||||
int Q_snprintf(char *buffer, size_t maxlen, const char *format, ...) LIKEPRINTF(3);
|
||||
int Q_vsnprintf(char *buffer, size_t maxlen, const char *format, va_list vargs);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NATIVEEXPORT
|
||||
#define NATIVEEXPORT QDECL
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef FTEPLUGIN
|
||||
#ifdef __cplusplus
|
||||
typedef enum {qfalse, qtrue} qboolean;
|
||||
#else
|
||||
typedef enum {qfalse, qtrue} qboolean;
|
||||
#define false qfalse
|
||||
#define true qtrue
|
||||
#endif
|
||||
typedef float vec3_t[3];
|
||||
typedef unsigned char qbyte;
|
||||
#endif
|
||||
typedef int qhandle_t;
|
||||
typedef void* funcptr_t;
|
||||
|
||||
|
@ -191,86 +114,13 @@ typedef struct {
|
|||
char name[PLUGMAX_SCOREBOARDNAME];
|
||||
int ping;
|
||||
int pl;
|
||||
int starttime;
|
||||
int activetime;
|
||||
int userid;
|
||||
int spectator;
|
||||
char userinfo[2048];
|
||||
char team[64];
|
||||
} plugclientinfo_t;
|
||||
|
||||
|
||||
|
||||
//Basic builtins:
|
||||
EBUILTIN(funcptr_t, Plug_GetEngineFunction, (const char *funcname)); //set up in vmMain, use this to get all other builtins
|
||||
|
||||
#ifdef FTEENGINE
|
||||
#else
|
||||
#ifndef Q3_VM
|
||||
EBUILTIN(qboolean, Plug_ExportNative, (const char *funcname, void *func)); //set up in vmMain, use this to get all other builtins
|
||||
EBUILTIN(void *, Plug_GetNativePointer, (const char *funcname));
|
||||
#endif
|
||||
EBUILTIN(void, Con_Print, (const char *text)); //on to main console.
|
||||
|
||||
EBUILTIN(qhandle_t, Con_POpen, (const char *conname, quintptr_t flags));
|
||||
EBUILTIN(void, Con_SubPrint, (const char *subname, const char *text)); //on to sub console.
|
||||
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));
|
||||
EBUILTIN(void, Con_NameForNum, (qintptr_t connum, char *conname, quintptr_t connamelen));
|
||||
EBUILTIN(float, Con_GetConsoleFloat, (const char *conname, const char *attribname));
|
||||
EBUILTIN(void, Con_SetConsoleFloat, (const char *conname, const char *attribname, float newvalue));
|
||||
EBUILTIN(int, Con_GetConsoleString, (const char *conname, const char *attribname, const char *value, quintptr_t valuesize));
|
||||
EBUILTIN(void, Con_SetConsoleString, (const char *conname, const char *attribname, const char *newvalue));
|
||||
|
||||
EBUILTIN(void, Sys_Error, (const char *message)); //abort the entire engine.
|
||||
EBUILTIN(quintptr_t, Sys_Milliseconds, (void));
|
||||
|
||||
EBUILTIN(int, Cmd_AddCommand, (const char *buffer)); //Registers a console command.
|
||||
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.
|
||||
EBUILTIN(int, Cmd_Argc, (void)); //abort the entire engine.
|
||||
EBUILTIN(void, Cmd_AddText, (const char *text, qboolean insert));
|
||||
EBUILTIN(void, Cmd_TokenizeString, (const char *msg)); //tokenize a string.
|
||||
|
||||
EBUILTIN(void, Cvar_SetString, (const char *name, const char *value));
|
||||
EBUILTIN(void, Cvar_SetFloat, (const char *name, float value));
|
||||
EBUILTIN(qboolean, Cvar_GetString, (const char *name, char *retstring, quintptr_t sizeofretstring));
|
||||
EBUILTIN(float, Cvar_GetFloat, (const char *name));
|
||||
EBUILTIN(qhandle_t, Cvar_Register, (const char *name, const char *defaultval, int flags, const char *grouphint));
|
||||
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.
|
||||
#ifdef FTEPLUGIN
|
||||
EBUILTIN(cvar_t*, Cvar_GetNVFDG, (const char *name, const char *defaultval, unsigned int flags, const char *description, const char *groupname));
|
||||
#endif
|
||||
|
||||
EBUILTIN(void, Plug_GetPluginName, (int plugnum, char *buffer, int bufsize));
|
||||
EBUILTIN(void, LocalSound, (const char *soundname));
|
||||
EBUILTIN(int, CL_GetStats, (int pnum, unsigned int *stats, int maxstats));
|
||||
EBUILTIN(int, GetPlayerInfo, (int pnum, plugclientinfo_t *info));
|
||||
|
||||
EBUILTIN(int, LocalPlayerNumber, (void)); //deprecated
|
||||
EBUILTIN(int, GetLocalPlayerNumbers, (int firstseat, int numseats, int *playernums, int *spectracks));
|
||||
EBUILTIN(void, GetServerInfo, (char *info, int infolen));
|
||||
EBUILTIN(void, SetUserInfo, (const char *key, const char *value));
|
||||
EBUILTIN(void, GetLocationName, (const float *pos, char *buffer, int bufferlen));
|
||||
#ifdef FTEPLUGIN
|
||||
EBUILTIN(int, GetLastInputFrame, (int seat, usercmd_t *playercmd));
|
||||
#endif
|
||||
EBUILTIN(float, GetTrackerOwnFrags, (int seat, char *text, size_t textsize));
|
||||
|
||||
EBUILTIN(qboolean, MapLog_Query, (const char *packagename, const char *mapname, float *stats));
|
||||
|
||||
#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
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int client;
|
||||
|
@ -280,11 +130,9 @@ typedef struct
|
|||
vec3_t org;
|
||||
char nick[16];
|
||||
} teamplayerinfo_t;
|
||||
EBUILTIN(int, GetTeamInfo, (teamplayerinfo_t *clients, unsigned int maxclients, int showenemies, int showself));
|
||||
struct wstats_s;
|
||||
EBUILTIN(int, GetWeaponStats, (int player, struct wstats_s *result, unsigned int maxresults));
|
||||
|
||||
typedef struct {
|
||||
size_t structsize;
|
||||
int seats;
|
||||
struct
|
||||
{
|
||||
|
@ -307,7 +155,7 @@ typedef struct {
|
|||
float vlatency;
|
||||
float vrate;
|
||||
vec3_t speed; //player speed
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
float in_pps;
|
||||
|
@ -323,84 +171,193 @@ typedef struct {
|
|||
float out_bps;
|
||||
} svrate;
|
||||
int capturing; //avi capturing
|
||||
} vmnetinfo_t;
|
||||
EBUILTIN(int, GetNetworkInfo, (vmnetinfo_t *ni, unsigned int sizeofni));
|
||||
} plugnetinfo_t;
|
||||
|
||||
struct wstats_s;
|
||||
|
||||
|
||||
EBUILTIN(void, Menu_Control, (int mnum));
|
||||
#define MENU_CLEAR 0
|
||||
#define MENU_GRAB 1
|
||||
EBUILTIN(int, Key_GetKeyCode, (const char *keyname));
|
||||
#define F(t, n, args) t (QDECL *n) args;
|
||||
|
||||
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.
|
||||
EBUILTIN(int, Draw_Image, (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t image));
|
||||
EBUILTIN(int, Draw_ImageSize, (qhandle_t image, float *x, float *y));
|
||||
EBUILTIN(void, Draw_Fill, (float x, float y, float w, float h));
|
||||
EBUILTIN(void, Draw_Line, (float x1, float y1, float x2, float y2));
|
||||
EBUILTIN(void, Draw_Character, (int x, int y, unsigned int character));
|
||||
EBUILTIN(void, Draw_String, (float x, float y, const char *string));
|
||||
EBUILTIN(void, Draw_CharacterH, (float x, float y, float h, unsigned int flags, unsigned int character));
|
||||
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));
|
||||
EBUILTIN(void, Draw_Colourpa, (int palcol, float a));
|
||||
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));
|
||||
EBUILTIN(void, SCR_CenterPrint, (const char *s));
|
||||
typedef struct //core stuff
|
||||
{
|
||||
//Basic builtins:
|
||||
F(void*, GetEngineInterface, (const char *interfacename, size_t structsize)); //retrieve a named interface struct from the engine
|
||||
F(qboolean, ExportFunction, (const char *funcname, funcptr_t funcptr)); //export a named function to the engine
|
||||
F(qboolean, ExportInterface, (const char *interfacename, void *interfaceptr, size_t structsize)); //export a named interface struct to the engine
|
||||
F(qboolean, GetPluginName, (int plugnum, char *buffer, size_t bufsize)); //query loaded plugin names. -1 == active plugin
|
||||
F(void, Print, (const char *message)); //print on (main) console.
|
||||
F(void, Error, (const char *message)); //abort the entire engine.
|
||||
F(quintptr_t,GetMilliseconds, (void));
|
||||
#define plugcorefuncs_name "Core"
|
||||
} plugcorefuncs_t;
|
||||
|
||||
EBUILTIN(void, S_RawAudio, (int sourceid, void *data, int speed, int samples, int channels, int width, float volume));
|
||||
typedef struct //subconsole handling
|
||||
{
|
||||
F(qhandle_t,POpen, (const char *conname));
|
||||
F(qboolean, SubPrint, (const char *subname, const char *text)); //on to sub console.
|
||||
F(qboolean, RenameSub, (const char *oldname, const char *newname)); //rename a console.
|
||||
F(qboolean, IsActive, (const char *conname));
|
||||
F(qboolean, SetActive, (const char *conname));
|
||||
F(qboolean, Destroy, (const char *conname));
|
||||
F(qboolean, NameForNum, (qintptr_t connum, char *conname, size_t connamelen));
|
||||
F(float, GetConsoleFloat, (const char *conname, const char *attribname));
|
||||
F(qboolean, SetConsoleFloat, (const char *conname, const char *attribname, float newvalue));
|
||||
F(qboolean, GetConsoleString, (const char *conname, const char *attribname, char *outvalue, size_t valuesize));
|
||||
F(qboolean, SetConsoleString, (const char *conname, const char *attribname, const char *newvalue));
|
||||
#define plugsubconsolefuncs_name "SubConsole"
|
||||
} plugsubconsolefuncs_t;
|
||||
|
||||
EBUILTIN(int, ReadInputBuffer, (void *inputbuffer, int buffersize));
|
||||
EBUILTIN(int, UpdateInputBuffer, (void *inputbuffer, int bytes));
|
||||
typedef struct //console command/tokenizing/cbuf functions
|
||||
{
|
||||
F(qboolean, AddCommand, (const char *buffer)); //Registers a console command.
|
||||
F(void, TokenizeString, (const char *msg)); //tokenize a string.
|
||||
|
||||
#if !defined(Q3_VM) && defined(FTEPLUGIN)
|
||||
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));
|
||||
#endif
|
||||
EBUILTIN(int, FS_Open, (const char *name, qhandle_t *handle, int mode));
|
||||
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));
|
||||
EBUILTIN(int, FS_Seek, (qhandle_t handle, unsigned int offsetlow, unsigned int offsethigh));
|
||||
EBUILTIN(qboolean, FS_GetLen, (qhandle_t handle, unsigned int *sizelow, unsigned int *sizehigh));
|
||||
F(void, Args, (char *buffer, int bufsize)); //Gets the extra args
|
||||
F(void, Argv, (int argnum, char *buffer, size_t bufsize)); //Gets a 0-based token
|
||||
F(int, Argc, (void)); //gets the number of tokens available.
|
||||
|
||||
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));
|
||||
EBUILTIN(int, Net_SetTLSClient, (qhandle_t sock, const char *certhostname));
|
||||
EBUILTIN(int, Net_GetTLSBinding, (qhandle_t sock, char *outdata, int *datalen));
|
||||
#define N_WOULDBLOCK -1
|
||||
#define N_FATALERROR -2
|
||||
#define NET_CLIENTPORT -1
|
||||
#define NET_SERVERPORT -2
|
||||
F(void, AddText, (const char *text, qboolean insert));
|
||||
#define plugcmdfuncs_name "Cmd"
|
||||
} plugcmdfuncs_t;
|
||||
|
||||
#ifdef Q3_VM
|
||||
EBUILTIN(void, memcpy, (void *, void *, int len));
|
||||
EBUILTIN(void, memmove, (void *, void *, int len));
|
||||
EBUILTIN(void, memset, (void *, int, int len));
|
||||
EBUILTIN(float, sqrt, (float f));
|
||||
EBUILTIN(float, cos, (float f));
|
||||
EBUILTIN(float, sin, (float f));
|
||||
#endif
|
||||
typedef struct //console command and cbuf functions
|
||||
{
|
||||
F(void, SetString, (const char *name, const char *value));
|
||||
F(void, SetFloat, (const char *name, float value));
|
||||
F(qboolean, GetString, (const char *name, char *retstring, quintptr_t sizeofretstring));
|
||||
F(float, GetFloat, (const char *name));
|
||||
F(qhandle_t,Register, (const char *name, const char *defaultval, int flags, const char *grouphint));
|
||||
F(qboolean, Update, (qhandle_t handle, int *modificationcount, char *outstringv, size_t stringsize, float *outfloatv)); //stringv is 256 chars long, don't expect this function to do anything if modification count is unchanged.
|
||||
F(cvar_t*, GetNVFDG, (const char *name, const char *defaultval, unsigned int flags, const char *description, const char *groupname));
|
||||
#define plugcvarfuncs_name "Cvar"
|
||||
} plugcvarfuncs_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
F(void, LocalSound, (const char *soundname, int channel, float volume));
|
||||
F(void, RawAudio, (int sourceid, void *data, int speed, int samples, int channels, int width, float volume));
|
||||
#define plugaudiofuncs_name "Audio"
|
||||
} plugaudiofuncs_t;
|
||||
|
||||
typedef struct //q1 client/network info
|
||||
{
|
||||
F(int, GetStats, (int seat, unsigned int *stats, int maxstats));
|
||||
F(void, GetPlayerInfo, (int seat, plugclientinfo_t *info));
|
||||
F(size_t, GetTeamInfo, (teamplayerinfo_t *clients, size_t maxclients, qboolean showenemies, int seat));
|
||||
F(int, GetWeaponStats, (int player, struct wstats_s *result, size_t maxresults));
|
||||
F(size_t, GetNetworkInfo, (plugnetinfo_t *ni, size_t sizeofni));
|
||||
F(size_t, GetLocalPlayerNumbers,(size_t firstseat, size_t numseats, int *playernums, int *spectracks));
|
||||
F(void, GetLocationName, (const float *pos, char *outbuffer, size_t bufferlen));
|
||||
F(float, GetTrackerOwnFrags, (int seat, char *text, size_t textsize));
|
||||
F(qboolean, GetLastInputFrame, (int seat, usercmd_t *outcmd));
|
||||
F(void, GetServerInfo, (char *info, size_t infolen));
|
||||
|
||||
F(void, SetUserInfo, (int seat, const char *key, const char *value));
|
||||
//EBUILTIN(void, SCR_CenterPrint, (const char *s));
|
||||
|
||||
//FIXME: does this belong here?
|
||||
F(qboolean, MapLog_Query, (const char *packagename, const char *mapname, float *stats));
|
||||
#define plugclientfuncs_name "Client"
|
||||
} plugclientfuncs_t;
|
||||
|
||||
typedef struct //for menu-like stuff
|
||||
{
|
||||
//for menus
|
||||
F(qboolean, SetMenuFocus, (qboolean wantkeyfocus, const char *cursorname, float hot_x, float hot_y, float scale)); //null cursorname=relmouse, set/empty cursorname=absmouse
|
||||
F(qboolean, HasMenuFocus, (void));
|
||||
|
||||
//for menu input
|
||||
F(int, GetKeyCode, (const char *keyname, int *out_modifier));
|
||||
F(const char*,GetKeyName, (int keycode, int modifier));
|
||||
F(int, FindKeysForCommand,(int bindmap, const char *command, int *out_keycodes, int *out_modifiers, int maxkeys));
|
||||
F(const char*,GetKeyBind, (int bindmap, int keynum, int modifier));
|
||||
F(void, SetKeyBind, (int bindmap, int keycode, int modifier, const char *newbinding));
|
||||
|
||||
#define pluginputfuncs_name "Input"
|
||||
} pluginputfuncs_t;
|
||||
|
||||
typedef struct //for huds and menus alike
|
||||
{
|
||||
//note: these use handles instead of shaders, to make them persistent over renderer restarts.
|
||||
F(qhandle_t,LoadImageData, (const char *name, const char *mime, void *data, size_t datasize)); //load/replace a named texture
|
||||
F(qhandle_t,LoadImageShader,(const char *name, const char *defaultshader)); //loads a shader.
|
||||
F(qhandle_t,LoadImage, (const char *name, qboolean iswadimage)); //wad image is ONLY for loading out of q1 gfx.wad. loads a shader.
|
||||
F(void, UnloadImage, (qhandle_t image));
|
||||
F(int, Image, (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t image));
|
||||
F(int, ImageSize, (qhandle_t image, float *x, float *y));
|
||||
F(void, Fill, (float x, float y, float w, float h));
|
||||
F(void, Line, (float x1, float y1, float x2, float y2));
|
||||
F(void, Character, (float x, float y, unsigned int character));
|
||||
F(void, String, (float x, float y, const char *string));
|
||||
F(void, CharacterH, (float x, float y, float h, unsigned int flags, unsigned int character));
|
||||
F(void, 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.
|
||||
F(float, StringWidth, (float h, unsigned int flags, const char *string));
|
||||
F(void, Colourpa, (int palcol, float a)); //for legacy code
|
||||
F(void, Colour4f, (float r, float g, float b, float a));
|
||||
|
||||
F(void, LocalSound, (const char *soundname, int channel, float volume));
|
||||
#define plug2dfuncs_name "2D"
|
||||
} plug2dfuncs_t;
|
||||
|
||||
typedef struct //for plugins that need to read/write files...
|
||||
{
|
||||
F(int, Open, (const char *name, qhandle_t *handle, int mode));
|
||||
F(void, Close, (qhandle_t handle));
|
||||
F(int, Write, (qhandle_t handle, void *data, int len));
|
||||
F(int, Read, (qhandle_t handle, void *data, int len));
|
||||
F(int, Seek, (qhandle_t handle, qofs_t offset));
|
||||
F(qboolean, GetLen, (qhandle_t handle, qofs_t *outsize));
|
||||
|
||||
|
||||
F(vfsfile_t*,OpenVFS, (const char *filename, const char *mode, enum fs_relative relativeto)); //opens a direct vfs file, without any access checks, and so can be used in threaded plugins
|
||||
F(qboolean, NativePath, (const char *name, enum fs_relative relativeto, char *out, int outlen));
|
||||
F(void, EnumerateFiles, (const char *match, int (QDECL *callback)(const char *fname, qofs_t fsize, time_t mtime, void *ctx, struct searchpathfuncs_s *package), void *ctx));
|
||||
#define plugfsfuncs_name "Filesystem"
|
||||
} plugfsfuncs_t;
|
||||
|
||||
typedef struct //for when you need basic socket access, hopefully rare...
|
||||
{
|
||||
F(qhandle_t,TCPConnect, (const char *ip, int port));
|
||||
F(qhandle_t,TCPListen, (const char *localip, int port, int maxcount));
|
||||
F(qhandle_t,Accept, (qhandle_t socket, char *address, int addresssize));
|
||||
F(int, Recv, (qhandle_t socket, void *buffer, int len));
|
||||
F(int, Send, (qhandle_t socket, void *buffer, int len));
|
||||
F(int, SendTo, (qhandle_t handle, void *data, int datasize, netadr_t *dest));
|
||||
F(void, Close, (qhandle_t socket));
|
||||
F(int, SetTLSClient, (qhandle_t sock, const char *certhostname)); //adds a tls layer to the socket (and specifies the peer's required hostname)
|
||||
F(int, GetTLSBinding, (qhandle_t sock, char *outdata, int *datalen)); //to avoid MITM attacks with compromised cert authorities
|
||||
#define N_WOULDBLOCK -1
|
||||
#define N_FATALERROR -2
|
||||
#define NET_CLIENTPORT -1
|
||||
#define NET_SERVERPORT -2
|
||||
#define plugnetfuncs_name "Net"
|
||||
} plugnetfuncs_t;
|
||||
|
||||
#undef F
|
||||
|
||||
extern plugcorefuncs_t *plugfuncs;
|
||||
extern plugcmdfuncs_t *cmdfuncs;
|
||||
extern plugcvarfuncs_t *cvarfuncs;
|
||||
|
||||
#ifndef FTEENGINE
|
||||
void Q_strlncpy(char *d, const char *s, int sizeofd, int lenofs);
|
||||
void Q_strlcpy(char *d, const char *s, int n);
|
||||
void Q_strlcat(char *d, const char *s, int n);
|
||||
#if defined(_MSC_VER) && _MSC_VER < 2015
|
||||
int Q_snprintf(char *buffer, size_t maxlen, const char *format, ...) LIKEPRINTF(3);
|
||||
int Q_vsnprintf(char *buffer, size_t maxlen, const char *format, va_list vargs);
|
||||
#else
|
||||
#define Q_snprintf snprintf
|
||||
#define Q_vsnprintf vsnprintf
|
||||
#endif
|
||||
|
||||
typedef qintptr_t (QDECL *export_t) (qintptr_t *args);
|
||||
char *va(const char *format, ...);
|
||||
qintptr_t Plug_Init(qintptr_t *args);
|
||||
qboolean Plug_Export(const char *name, export_t func);
|
||||
qboolean Plug_Init(void);
|
||||
void Con_Printf(const char *format, ...);
|
||||
void Con_DPrintf(const char *format, ...); //not a particuarly efficient implementation, so beware.
|
||||
void Sys_Errorf(const char *format, ...);
|
||||
void QDECL Q_strncpyz(char *d, const char *s, int n);
|
||||
|
||||
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,...));
|
||||
|
||||
#define PLUG_SHARED_BEGIN(t,p,b) \
|
||||
{ \
|
||||
t *p; \
|
||||
|
@ -412,12 +369,6 @@ NATIVEEXPORT void QDECL dllEntry(qintptr_t (QDECL *funcptr)(qintptr_t,...));
|
|||
p = NULL;
|
||||
#define PLUG_SHARED_END(p,b) UpdateInputBuffer(inputbuffer, b);}
|
||||
|
||||
|
||||
//
|
||||
// qvm_api.c
|
||||
//
|
||||
//int vsnprintf(char *buffer, size_t maxlen, const char *format, va_list vargs);
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char string[256];
|
||||
|
@ -428,12 +379,8 @@ typedef struct {
|
|||
int modificationcount;
|
||||
} vmcvar_t;
|
||||
|
||||
typedef struct {
|
||||
int width;
|
||||
int height;
|
||||
} vmvideo_t;
|
||||
extern vmvideo_t pvid;
|
||||
|
||||
#define VMCvar_Register(cv) (cv->handle=cvarfuncs->Register(cv->name, cv->string, cv->flags, cv->group))
|
||||
#define VMCvar_Update(cv) cvarfuncs->Update(handle, &cv->modcount, cv->string, sizeof(cv->string), &cv->value)
|
||||
#define VMCvar_SetString(c,v) \
|
||||
do{ \
|
||||
strcpy(c->string, v); \
|
||||
|
@ -448,18 +395,10 @@ extern vmvideo_t pvid;
|
|||
} while(0) \
|
||||
|
||||
|
||||
#ifndef MAX_INFO_KEY
|
||||
#define MAX_INFO_KEY 64
|
||||
#endif
|
||||
char *Plug_Info_ValueForKey (const char *s, const char *key, char *out, size_t outsize);
|
||||
void Info_RemoveKey (char *s, const char *key);
|
||||
void Info_RemovePrefixedKeys (char *start, char prefix);
|
||||
void Info_RemoveNonStarKeys (char *start);
|
||||
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);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue