Small revision.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1152 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
891e7f0503
commit
2964c0be1a
3 changed files with 128 additions and 4 deletions
|
@ -48,10 +48,24 @@ BUILTINR(int, Plug_ExportToEngine, (char *funcname, int expnum));
|
||||||
BUILTIN(void, Con_Print, (char *text)); //on to main console.
|
BUILTIN(void, Con_Print, (char *text)); //on to main console.
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
|
||||||
|
#define ARGNAMES ,conname,text
|
||||||
|
BUILTIN(void, Con_SubPrint, (char *conname, char *text)); //on to named sub console (creating it too).
|
||||||
|
#undef ARGNAMES
|
||||||
|
|
||||||
|
#define ARGNAMES ,old,new
|
||||||
|
BUILTIN(void, Con_RenameSub, (char *old, char *new)); //on to named sub console (creating it too).
|
||||||
|
#undef ARGNAMES
|
||||||
|
|
||||||
#define ARGNAMES ,message
|
#define ARGNAMES ,message
|
||||||
BUILTIN(void, Sys_Error, (char *message)); //abort the entire engine.
|
BUILTIN(void, Sys_Error, (char *message)); //abort the entire engine.
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
#define ARGNAMES
|
||||||
|
BUILTINR(unsigned int, Sys_Milliseconds, (void)); //abort the entire engine.
|
||||||
|
#undef ARGNAMES
|
||||||
|
|
||||||
|
#define ARGNAMES ,buffer
|
||||||
|
BUILTIN(void, Cmd_AddCommand, (char *buffer)); //abort the entire engine.
|
||||||
|
#undef ARGNAMES
|
||||||
#define ARGNAMES ,buffer,bufsize
|
#define ARGNAMES ,buffer,bufsize
|
||||||
BUILTIN(void, Cmd_Args, (char *buffer, int bufsize)); //abort the entire engine.
|
BUILTIN(void, Cmd_Args, (char *buffer, int bufsize)); //abort the entire engine.
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
@ -115,6 +129,10 @@ BUILTIN(void, Draw_Colour3f, (float r, float g, float b));
|
||||||
BUILTIN(void, Draw_Colour4f, (float r, float g, float b, float a));
|
BUILTIN(void, Draw_Colour4f, (float r, float g, float b, float a));
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
|
||||||
|
#define ARGNAMES ,src,srcwidth,srcheight,x,y,width,height
|
||||||
|
BUILTIN(void, Media_ShowFrameRGBA_32, (void *src, int srcwidth, int srcheight, int x, int y, int width, int height));
|
||||||
|
#undef ARGNAMES
|
||||||
|
|
||||||
#define ARGNAMES ,mnum
|
#define ARGNAMES ,mnum
|
||||||
BUILTIN(void, Menu_Control, (int mnum));
|
BUILTIN(void, Menu_Control, (int mnum));
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
@ -123,6 +141,34 @@ BUILTIN(void, Menu_Control, (int mnum));
|
||||||
BUILTINR(int, Key_GetKeyCode, (char *keyname));
|
BUILTINR(int, Key_GetKeyCode, (char *keyname));
|
||||||
#undef ARGNAMES
|
#undef ARGNAMES
|
||||||
|
|
||||||
|
#define ARGNAMES ,ip,port
|
||||||
|
BUILTINR(int, Net_TCPConnect, (char *ip, int port));
|
||||||
|
#undef ARGNAMES
|
||||||
|
#define ARGNAMES ,ip,port,maxcount
|
||||||
|
BUILTINR(int, Net_TCPListen, (char *ip, int port, int maxcount));
|
||||||
|
#undef ARGNAMES
|
||||||
|
#define ARGNAMES ,socket,address,addresslen
|
||||||
|
BUILTINR(int, Net_Accept, (int socket, char *address, int addresslen));
|
||||||
|
#undef ARGNAMES
|
||||||
|
#define ARGNAMES ,socket,buffer,len
|
||||||
|
BUILTINR(int, Net_Recv, (int socket, void *buffer, int len));
|
||||||
|
#undef ARGNAMES
|
||||||
|
#define ARGNAMES ,socket,buffer,len
|
||||||
|
BUILTINR(int, Net_Send, (int socket, void *buffer, int len));
|
||||||
|
#undef ARGNAMES
|
||||||
|
#define ARGNAMES ,socket
|
||||||
|
BUILTIN(void, Net_Close, (int socket));
|
||||||
|
#undef ARGNAMES
|
||||||
|
|
||||||
|
#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
|
||||||
|
#endif
|
||||||
|
|
||||||
char *va(char *format, ...) //Identical in function to the one in Quake, though I can assure you that I wrote it...
|
char *va(char *format, ...) //Identical in function to the one in Quake, though I can assure you that I wrote it...
|
||||||
{ //It's not exactly hard, just easy to use, so gets duplicated lots.
|
{ //It's not exactly hard, just easy to use, so gets duplicated lots.
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
@ -160,15 +206,24 @@ void Sys_Errorf(char *format, ...)
|
||||||
|
|
||||||
void Plug_InitStandardBuiltins(void)
|
void Plug_InitStandardBuiltins(void)
|
||||||
{
|
{
|
||||||
|
#ifdef Q3_VM
|
||||||
|
CHECKBUILTIN(memcpy);
|
||||||
|
CHECKBUILTIN(memset);
|
||||||
|
#endif
|
||||||
|
|
||||||
CHECKBUILTIN(Plug_ExportToEngine);
|
CHECKBUILTIN(Plug_ExportToEngine);
|
||||||
CHECKBUILTIN(Con_Print);
|
CHECKBUILTIN(Con_Print);
|
||||||
CHECKBUILTIN(Sys_Error);
|
CHECKBUILTIN(Sys_Error);
|
||||||
|
CHECKBUILTIN(Sys_Milliseconds);
|
||||||
|
|
||||||
|
//command execution
|
||||||
|
CHECKBUILTIN(Cmd_AddCommand);
|
||||||
CHECKBUILTIN(Cmd_Args);
|
CHECKBUILTIN(Cmd_Args);
|
||||||
CHECKBUILTIN(Cmd_Argv);
|
CHECKBUILTIN(Cmd_Argv);
|
||||||
CHECKBUILTIN(Cmd_Argc);
|
CHECKBUILTIN(Cmd_Argc);
|
||||||
CHECKBUILTIN(Cmd_AddText);
|
CHECKBUILTIN(Cmd_AddText);
|
||||||
|
|
||||||
|
//cvar stuff
|
||||||
CHECKBUILTIN(Cvar_SetString);
|
CHECKBUILTIN(Cvar_SetString);
|
||||||
CHECKBUILTIN(Cvar_SetFloat);
|
CHECKBUILTIN(Cvar_SetFloat);
|
||||||
CHECKBUILTIN(Cvar_GetString);
|
CHECKBUILTIN(Cvar_GetString);
|
||||||
|
@ -176,11 +231,21 @@ void Plug_InitStandardBuiltins(void)
|
||||||
CHECKBUILTIN(Cvar_Register);
|
CHECKBUILTIN(Cvar_Register);
|
||||||
CHECKBUILTIN(Cvar_Update);
|
CHECKBUILTIN(Cvar_Update);
|
||||||
|
|
||||||
|
//networking
|
||||||
|
CHECKBUILTIN(Net_TCPConnect);
|
||||||
|
CHECKBUILTIN(Net_TCPListen);
|
||||||
|
CHECKBUILTIN(Net_Accept);
|
||||||
|
CHECKBUILTIN(Net_Recv);
|
||||||
|
CHECKBUILTIN(Net_Send);
|
||||||
|
CHECKBUILTIN(Net_Close);
|
||||||
|
|
||||||
|
//random things
|
||||||
CHECKBUILTIN(CL_GetStats);
|
CHECKBUILTIN(CL_GetStats);
|
||||||
CHECKBUILTIN(LocalSound);
|
CHECKBUILTIN(LocalSound);
|
||||||
CHECKBUILTIN(Menu_Control);
|
CHECKBUILTIN(Menu_Control);
|
||||||
CHECKBUILTIN(Key_GetKeyCode);
|
CHECKBUILTIN(Key_GetKeyCode);
|
||||||
|
|
||||||
|
//drawing routines
|
||||||
CHECKBUILTIN(Draw_LoadImage);
|
CHECKBUILTIN(Draw_LoadImage);
|
||||||
CHECKBUILTIN(Draw_Image);
|
CHECKBUILTIN(Draw_Image);
|
||||||
CHECKBUILTIN(Draw_Fill);
|
CHECKBUILTIN(Draw_Fill);
|
||||||
|
@ -188,6 +253,13 @@ void Plug_InitStandardBuiltins(void)
|
||||||
CHECKBUILTIN(Draw_Colourp);
|
CHECKBUILTIN(Draw_Colourp);
|
||||||
CHECKBUILTIN(Draw_Colour3f);
|
CHECKBUILTIN(Draw_Colour3f);
|
||||||
CHECKBUILTIN(Draw_Colour4f);
|
CHECKBUILTIN(Draw_Colour4f);
|
||||||
|
|
||||||
|
CHECKBUILTIN(Media_ShowFrameRGBA_32);
|
||||||
|
|
||||||
|
//sub consoles (optional)
|
||||||
|
CHECKBUILTIN(Con_SubPrint);
|
||||||
|
CHECKBUILTIN(Con_RenameSub);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q3_VM
|
#ifndef Q3_VM
|
||||||
|
@ -241,3 +313,6 @@ exports_t exports[sizeof(exports)/sizeof(exports[0])] = {
|
||||||
{"Plug_Init", Plug_InitAPI},
|
{"Plug_Init", Plug_InitAPI},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifndef __PLUGIN_H__
|
||||||
|
#define __PLUGIN_H__
|
||||||
#ifdef Q3_VM
|
#ifdef Q3_VM
|
||||||
|
|
||||||
//qvms just call the return value, and the engine works out which one it called.
|
//qvms just call the return value, and the engine works out which one it called.
|
||||||
|
@ -43,8 +45,12 @@ typedef void *qhandle_t;
|
||||||
//Basic builtins:
|
//Basic builtins:
|
||||||
EBUILTIN(void*, Plug_GetEngineFunction, (char *funcname)); //set up in vmMain, use this to get all other builtins
|
EBUILTIN(void*, Plug_GetEngineFunction, (char *funcname)); //set up in vmMain, use this to get all other builtins
|
||||||
EBUILTIN(void, Con_Print, (char *text)); //on to main console.
|
EBUILTIN(void, Con_Print, (char *text)); //on to main console.
|
||||||
|
EBUILTIN(void, Con_SubPrint, (char *subname, char *text)); //on to sub console.
|
||||||
|
EBUILTIN(void, Con_RenameSub, (char *old, char *new)); //rename a console.
|
||||||
EBUILTIN(void, Sys_Error, (char *message)); //abort the entire engine.
|
EBUILTIN(void, Sys_Error, (char *message)); //abort the entire engine.
|
||||||
|
EBUILTIN(unsigned int, Sys_Milliseconds, ());
|
||||||
|
|
||||||
|
EBUILTIN(void, Cmd_AddCommand, (char *buffer)); //abort the entire engine.
|
||||||
EBUILTIN(void, Cmd_Args, (char *buffer, int bufsize)); //abort the entire engine.
|
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(void, Cmd_Argv, (int argnum, char *buffer, int bufsize)); //abort the entire engine.
|
||||||
EBUILTIN(void, Cmd_Argc, (void)); //abort the entire engine.
|
EBUILTIN(void, Cmd_Argc, (void)); //abort the entire engine.
|
||||||
|
@ -61,7 +67,10 @@ EBUILTIN(void, LocalSound, (char *soundname));
|
||||||
EBUILTIN(void, CL_GetStats, (int pnum, unsigned int *stats, int maxstats));
|
EBUILTIN(void, CL_GetStats, (int pnum, unsigned int *stats, int maxstats));
|
||||||
|
|
||||||
EBUILTIN(void, Menu_Control, (int mnum));
|
EBUILTIN(void, Menu_Control, (int mnum));
|
||||||
|
#define MENU_CLEAR 0
|
||||||
|
#define MENU_GRAB 1
|
||||||
EBUILTIN(int, Key_GetKeyCode, (char *keyname));
|
EBUILTIN(int, Key_GetKeyCode, (char *keyname));
|
||||||
|
EBUILTIN(void, Media_ShowFrameRGBA_32, (void *src, int srcwidth, int srcheight, int x, int y, int width, int height));
|
||||||
|
|
||||||
EBUILTIN(qhandle_t, Draw_LoadImage, (char *name, qboolean iswadimage)); //wad image is ONLY for loading out of q1 gfx.wad
|
EBUILTIN(qhandle_t, Draw_LoadImage, (char *name, qboolean iswadimage)); //wad image is ONLY for loading out of q1 gfx.wad
|
||||||
EBUILTIN(void, Draw_Image, (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t image));
|
EBUILTIN(void, Draw_Image, (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t image));
|
||||||
|
@ -71,6 +80,21 @@ EBUILTIN(void, Draw_Colourp, (int palcol));
|
||||||
EBUILTIN(void, Draw_Colour3f, (float r, float g, float b));
|
EBUILTIN(void, Draw_Colour3f, (float r, float g, float b));
|
||||||
EBUILTIN(void, Draw_Colour4f, (float r, float g, float b, float a));
|
EBUILTIN(void, Draw_Colour4f, (float r, float g, float b, float a));
|
||||||
|
|
||||||
|
EBUILTIN(int, Net_TCPConnect, (char *ip, int port));
|
||||||
|
EBUILTIN(int, Net_TCPListen, (char *ip, int port, int maxcount));
|
||||||
|
EBUILTIN(int, Net_Accept, (int socket, char *address, int addresssize));
|
||||||
|
EBUILTIN(int, Net_Recv, (int socket, void *buffer, int len));
|
||||||
|
EBUILTIN(int, Net_Send, (int socket, void *buffer, int len));
|
||||||
|
EBUILTIN(void, Net_Close, (int socket));
|
||||||
|
#define N_WOULDBLOCK -1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef Q3_VM
|
||||||
|
EBUILTIN(void, memcpy, (void *, void *, int len));
|
||||||
|
EBUILTIN(void, memset, (void *, int, int len));
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int (*export_t) (int *args);
|
typedef int (*export_t) (int *args);
|
||||||
char *va(char *format, ...);
|
char *va(char *format, ...);
|
||||||
int Plug_Init(int *args);
|
int Plug_Init(int *args);
|
||||||
|
@ -78,6 +102,7 @@ qboolean Plug_Export(char *name, export_t func);
|
||||||
void Con_Printf(char *format, ...);
|
void Con_Printf(char *format, ...);
|
||||||
void Sys_Errorf(char *format, ...);
|
void Sys_Errorf(char *format, ...);
|
||||||
typedef unsigned char qbyte;
|
typedef unsigned char qbyte;
|
||||||
|
void Q_strncpyz(char *d, const char *s, int n);
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -118,3 +143,4 @@ void Info_RemoveNonStarKeys (char *start);
|
||||||
void Info_SetValueForKey (char *s, char *key, char *value, int maxsize);
|
void Info_SetValueForKey (char *s, char *key, char *value, int maxsize);
|
||||||
void Info_SetValueForStarKey (char *s, char *key, char *value, int maxsize);
|
void Info_SetValueForStarKey (char *s, char *key, char *value, int maxsize);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -136,7 +136,7 @@ retry:
|
||||||
tokens++;
|
tokens++;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
_float = va_arg(vargs, double);
|
_float = (float)va_arg(vargs, double);
|
||||||
|
|
||||||
//integer part.
|
//integer part.
|
||||||
_int = (int)_float;
|
_int = (int)_float;
|
||||||
|
@ -149,10 +149,17 @@ retry:
|
||||||
}
|
}
|
||||||
i = sizeof(tempbuffer)-2;
|
i = sizeof(tempbuffer)-2;
|
||||||
tempbuffer[sizeof(tempbuffer)-1] = '\0';
|
tempbuffer[sizeof(tempbuffer)-1] = '\0';
|
||||||
while(_int)
|
if (!_int)
|
||||||
{
|
{
|
||||||
tempbuffer[i--] = _int%10 + '0';
|
tempbuffer[i--] = '0';
|
||||||
_int/=10;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(_int)
|
||||||
|
{
|
||||||
|
tempbuffer[i--] = _int%10 + '0';
|
||||||
|
_int/=10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
string = tempbuffer+i+1;
|
string = tempbuffer+i+1;
|
||||||
while (*string)
|
while (*string)
|
||||||
|
@ -289,3 +296,19 @@ char *strstr(char *str, char *sub)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Q_strncpyz(char *d, const char *s, int n)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
n--;
|
||||||
|
if (n < 0)
|
||||||
|
return; //this could be an error
|
||||||
|
|
||||||
|
for (i=0; *s; i++)
|
||||||
|
{
|
||||||
|
if (i == n)
|
||||||
|
break;
|
||||||
|
*d++ = *s++;
|
||||||
|
}
|
||||||
|
*d='\0';
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue