Allowed plugins a way to get location info from the engine

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2707 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2007-10-05 10:46:26 +00:00
parent c6325976f0
commit bdebba9bfa
2 changed files with 39 additions and 20 deletions

View file

@ -373,6 +373,8 @@ int VARGS Plug_GetPlayerInfo(void *offset, unsigned int mask, const int *arg)
i = VM_LONG(arg[0]);
out = VM_POINTER(arg[1]);
if (out)
{
if (i == -1)
{
i = cl.playernum[0];
@ -393,6 +395,7 @@ int VARGS Plug_GetPlayerInfo(void *offset, unsigned int mask, const int *arg)
out->spectator = cl.players[i].spectator;
Q_strncpyz(out->userinfo, cl.players[i].userinfo, sizeof(out->userinfo));
Q_strncpyz(out->team, cl.players[i].team, sizeof(out->team));
}
pt = Cam_TrackNum(0);
if (pt < 0)
@ -409,7 +412,7 @@ int VARGS Plug_LocalPlayerNumber(void *offset, unsigned int mask, const int *arg
int VARGS Plug_GetServerInfo(void *offset, unsigned int mask, const int *arg)
{
char *outptr = VM_POINTER(arg[0]);
int outlen = VM_LONG(arg[1]);
unsigned int outlen = VM_LONG(arg[1]);
if (VM_OOB(arg[0], outlen))
return false;
@ -429,6 +432,21 @@ int VARGS Plug_SetUserInfo(void *offset, unsigned int mask, const int *arg)
return true;
}
int VARGS Plug_GetLocationName(void *offset, unsigned int mask, const int *arg)
{
float *locpoint = VM_POINTER(arg[0]);
char *locname = VM_POINTER(arg[1]);
unsigned int locnamelen = VM_LONG(arg[2]);
char *result;
if (VM_OOB(arg[1], locnamelen))
return 0;
result = TP_LocationName(locpoint);
Q_strncpyz(locname, result, locnamelen);
return VM_LONG(arg[1]);
}
int VARGS Plug_Con_SubPrint(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
@ -548,6 +566,7 @@ void Plug_Client_Init(void)
Plug_RegisterBuiltin("SCR_CenterPrint", Plug_SCR_CenterPrint, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("Media_ShowFrameRGBA_32", Plug_Media_ShowFrameRGBA_32, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("GetLocationName", Plug_GetLocationName, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("GetPlayerInfo", Plug_GetPlayerInfo, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("LocalPlayerNumber", Plug_LocalPlayerNumber, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("GetServerInfo", Plug_GetServerInfo, PLUG_BIF_NEEDSRENDERER);

View file

@ -172,7 +172,7 @@ extern cvar_t host_mapname;
static void TP_FindModelNumbers (void);
static void TP_FindPoint (void);
static char *TP_LocationName (vec3_t location);
char *TP_LocationName (vec3_t location);
#define MAX_LOC_NAME 48
@ -1509,7 +1509,7 @@ static void TP_LoadLocFile_f (void)
TP_LoadLocFile (Cmd_Argv(1), false);
}
static char *TP_LocationName (vec3_t location)
char *TP_LocationName (vec3_t location)
{
int i, minnum;
float dist, mindist;