1
0
Fork 0
forked from fte/fteqw

Some new stuff for the hud plugin.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1884 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2006-01-21 00:07:47 +00:00
parent e3cb464de9
commit 48514d4807
3 changed files with 71 additions and 4 deletions

View file

@ -116,6 +116,9 @@ BUILTINR(int, Cvar_Update, (qhandle_t handle, int *modificationcount, char *stri
#define ARGNAMES ,pnum,stats,maxstats #define ARGNAMES ,pnum,stats,maxstats
BUILTIN(void, CL_GetStats, (int pnum, unsigned int *stats, int maxstats)); BUILTIN(void, CL_GetStats, (int pnum, unsigned int *stats, int maxstats));
#undef ARGNAMES #undef ARGNAMES
#define ARGNAMES ,pnum,info
BUILTIN(int, GetPlayerInfo, (int pnum, plugclientinfo_t *info));
#undef ARGNAMES
#define ARGNAMES ,soundname #define ARGNAMES ,soundname
BUILTIN(void, LocalSound, (char *soundname)); BUILTIN(void, LocalSound, (char *soundname));
@ -306,6 +309,7 @@ void Plug_InitStandardBuiltins(void)
//random things //random things
CHECKBUILTIN(CL_GetStats); CHECKBUILTIN(CL_GetStats);
CHECKBUILTIN(GetPlayerInfo);
CHECKBUILTIN(LocalSound); CHECKBUILTIN(LocalSound);
CHECKBUILTIN(Menu_Control); CHECKBUILTIN(Menu_Control);
CHECKBUILTIN(Key_GetKeyCode); CHECKBUILTIN(Key_GetKeyCode);

View file

@ -82,6 +82,24 @@ typedef float vec3_t[3];
typedef void* funcptr_t; typedef void* funcptr_t;
#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;
char userinfo[1024];
char team[8];
} plugclientinfo_t;
//Basic builtins: //Basic builtins:
EBUILTIN(funcptr_t, Plug_GetEngineFunction, (char *funcname)); //set up in vmMain, use this to get all other builtins EBUILTIN(funcptr_t, Plug_GetEngineFunction, (char *funcname)); //set up in vmMain, use this to get all other builtins
@ -114,6 +132,7 @@ EBUILTIN(int, Cvar_Update, (qhandle_t handle, int *modificationcount, char *stri
EBUILTIN(void, GetPluginName, (int plugnum, char *buffer, int bufsize)); EBUILTIN(void, GetPluginName, (int plugnum, char *buffer, int bufsize));
EBUILTIN(void, LocalSound, (char *soundname)); 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(int, GetPlayerInfo, (int pnum, plugclientinfo_t *info));
EBUILTIN(void, Menu_Control, (int mnum)); EBUILTIN(void, Menu_Control, (int mnum));
#define MENU_CLEAR 0 #define MENU_CLEAR 0

View file

@ -18,7 +18,7 @@ int vsnprintf(char *buffer, int maxlen, char *format, va_list vargs)
int _int; int _int;
float _float; float _float;
int i; int i;
int use0s; int use0s, useprepad;
int precision; int precision;
if (!maxlen) if (!maxlen)
@ -31,10 +31,14 @@ maxlen--;
{ {
case '%': case '%':
precision= 0; precision= 0;
useprepad=0;
use0s=0; use0s=0;
retry: retry:
switch(*(++format)) switch(*(++format))
{ {
case '-':
useprepad=true;
goto retry;
case '0': case '0':
if (!precision) if (!precision)
{ {
@ -140,6 +144,38 @@ retry:
case 'u': case 'u':
case 'i': case 'i':
_int = va_arg(vargs, int); _int = va_arg(vargs, int);
/*
if (useprepad)
{
if (_int >= 1000)
useprepad = 4;
else if (_int >= 100)
useprepad = 3;
else if (_int >= 10)
useprepad = 2;
else if (_int >= 0)
useprepad = 1;
else if (_int <= -1000)
useprepad = 5;
else if (_int <= -100)
useprepad = 4;
else if (_int <= -10)
useprepad = 3;
else
useprepad = 2;
useprepad = precision - useprepad;
Con_Printf("add %i chars\n", useprepad);
while (useprepad>0)
{
if (--maxlen < 0)
{*buffer++='\0';return tokens;}
*buffer++ = ' ';
useprepad--;
}
Con_Printf("%i bytes left\n", maxlen);
}
*/
if (_int < 0) if (_int < 0)
{ {
if (--maxlen < 0) if (--maxlen < 0)
@ -166,15 +202,23 @@ retry:
} }
precision -= 62-i; precision -= 62-i;
while (precision>0) /* while (precision>0)
{ {
string--; string--;
if (use0s)
*string = '0';
else
*string = ' '; *string = ' ';
precision--; precision--;
} }
*/
while(precision>0)
{
if (--maxlen < 0)
{*buffer++='\0';return tokens;}
if (use0s)
*buffer++ = '0';
else
*buffer++ = ' ';
precision--;
}
while (*string) while (*string)
{ {