From bdebba9bfacd55bf340cade5f133bc9e7949a7a8 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 5 Oct 2007 10:46:26 +0000 Subject: [PATCH] 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 --- engine/client/cl_plugin.inc | 55 +++++++++++++++++++++++++------------ engine/client/zqtp.c | 4 +-- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/engine/client/cl_plugin.inc b/engine/client/cl_plugin.inc index 1a651a3ea..5455e98bb 100644 --- a/engine/client/cl_plugin.inc +++ b/engine/client/cl_plugin.inc @@ -373,26 +373,29 @@ int VARGS Plug_GetPlayerInfo(void *offset, unsigned int mask, const int *arg) i = VM_LONG(arg[0]); out = VM_POINTER(arg[1]); - if (i == -1) + if (out) { - i = cl.playernum[0]; - if (i < 0) + if (i == -1) { - memset(out, 0, sizeof(*out)); - return 0; - } + i = cl.playernum[0]; + if (i < 0) + { + memset(out, 0, sizeof(*out)); + return 0; + } + } + out->bottomcolour = cl.players[i].rbottomcolor; + out->topcolour = cl.players[i].rtopcolor; + out->frags = cl.players[i].frags; + Q_strncpyz(out->name, cl.players[i].name, PLUGMAX_SCOREBOARDNAME); + out->ping = cl.players[i].ping; + out->pl = cl.players[i].pl; + out->starttime = cl.players[i].entertime; + out->userid = cl.players[i].userid; + 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)); } - out->bottomcolour = cl.players[i].rbottomcolor; - out->topcolour = cl.players[i].rtopcolor; - out->frags = cl.players[i].frags; - Q_strncpyz(out->name, cl.players[i].name, PLUGMAX_SCOREBOARDNAME); - out->ping = cl.players[i].ping; - out->pl = cl.players[i].pl; - out->starttime = cl.players[i].entertime; - out->userid = cl.players[i].userid; - 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); diff --git a/engine/client/zqtp.c b/engine/client/zqtp.c index cacfbbdd0..da42c8dfd 100644 --- a/engine/client/zqtp.c +++ b/engine/client/zqtp.c @@ -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;