2005-12-15 19:41:11 +00:00
|
|
|
//included directly from plugin.c
|
|
|
|
//this is the client-only things.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static plugin_t *menuplug; //plugin that has the current menu
|
|
|
|
static plugin_t *protocolclientplugin;
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Menu_Control(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return 0;
|
|
|
|
|
2005-12-15 19:41:11 +00:00
|
|
|
switch(VM_LONG(arg[0]))
|
|
|
|
{
|
|
|
|
case 0: //take away all menus
|
|
|
|
case 1:
|
|
|
|
if (menuplug)
|
|
|
|
{
|
|
|
|
plugin_t *oldplug = currentplug;
|
|
|
|
currentplug = menuplug;
|
|
|
|
Plug_Menu_Event(3, 0);
|
|
|
|
menuplug = NULL;
|
|
|
|
currentplug = oldplug;
|
|
|
|
key_dest = key_game;
|
|
|
|
}
|
|
|
|
if (VM_LONG(arg[0]) != 1)
|
|
|
|
return 1;
|
|
|
|
//give us menu control
|
|
|
|
menuplug = currentplug;
|
|
|
|
key_dest = key_menu;
|
|
|
|
m_state = m_plugin;
|
|
|
|
return 1;
|
|
|
|
case 2: //weather it's us or not.
|
|
|
|
return currentplug == menuplug && m_state == m_plugin;
|
|
|
|
case 3: //weather a menu is active
|
|
|
|
return key_dest == key_menu;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Key_GetKeyCode(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
int modifier;
|
|
|
|
return Key_StringToKeynum(VM_POINTER(arg[0]), &modifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_SCR_CenterPrint(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return 0;
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
SCR_CenterPrint(0, VM_POINTER(arg[0]), true);
|
2005-12-15 19:41:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
//Make SURE that the engine has resolved all cvar pointers into globals before this happens.
|
|
|
|
plugin_t *plugin;
|
|
|
|
char name[64];
|
|
|
|
qboolean picfromwad;
|
|
|
|
mpic_t *pic;
|
|
|
|
} pluginimagearray_t;
|
|
|
|
int pluginimagearraylen;
|
|
|
|
pluginimagearray_t *pluginimagearray;
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_LoadImage(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
char *name = VM_POINTER(arg[0]);
|
|
|
|
qboolean fromwad = arg[1];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
mpic_t *pic;
|
|
|
|
|
2006-02-13 01:00:56 +00:00
|
|
|
if (!*name)
|
|
|
|
return 0;
|
|
|
|
|
2005-12-15 19:41:11 +00:00
|
|
|
for (i = 0; i < pluginimagearraylen; i++)
|
|
|
|
{
|
|
|
|
if (!pluginimagearray[i].plugin)
|
|
|
|
break;
|
|
|
|
if (pluginimagearray[i].plugin == currentplug)
|
|
|
|
{
|
|
|
|
if (!strcmp(name, pluginimagearray[i].name))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == pluginimagearraylen)
|
|
|
|
{
|
|
|
|
pluginimagearraylen++;
|
|
|
|
pluginimagearray = BZ_Realloc(pluginimagearray, pluginimagearraylen*sizeof(pluginimagearray_t));
|
2008-05-09 14:22:37 +00:00
|
|
|
pluginimagearray[i].pic = NULL;
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginimagearray[i].pic)
|
2008-02-19 12:36:51 +00:00
|
|
|
return i+1; //already loaded.
|
2005-12-15 19:41:11 +00:00
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer != QR_NONE)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
2011-03-31 01:14:01 +00:00
|
|
|
if (fromwad)
|
|
|
|
pic = R2D_SafePicFromWad(name);
|
2005-12-15 19:41:11 +00:00
|
|
|
else
|
2011-03-31 01:14:01 +00:00
|
|
|
pic = R2D_SafeCachePic(name);
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pic = NULL;
|
|
|
|
|
|
|
|
Q_strncpyz(pluginimagearray[i].name, name, sizeof(pluginimagearray[i].name));
|
|
|
|
pluginimagearray[i].picfromwad = fromwad;
|
|
|
|
pluginimagearray[i].pic = pic;
|
|
|
|
pluginimagearray[i].plugin = currentplug;
|
2006-02-13 01:00:56 +00:00
|
|
|
return i + 1;
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Plug_DrawReloadImages(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < pluginimagearraylen; i++)
|
|
|
|
{
|
|
|
|
if (!pluginimagearray[i].plugin)
|
|
|
|
{
|
|
|
|
pluginimagearray[i].pic = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
pluginimagearray[i].pic = R2D_SafePicFromWad(pluginimagearray[i].name);
|
|
|
|
//pluginimagearray[i].pic = R2D_SafeCachePic(pluginimagearray[i].name);
|
|
|
|
//pluginimagearray[i].pic = NULL;
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Plug_FreePlugImages(plugin_t *plug)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < pluginimagearraylen; i++)
|
|
|
|
{
|
|
|
|
if (pluginimagearray[i].plugin == plug)
|
|
|
|
{
|
|
|
|
pluginimagearray[i].plugin = 0;
|
|
|
|
pluginimagearray[i].pic = NULL;
|
|
|
|
pluginimagearray[i].name[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
//int R2D_Image (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t image)
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_Image(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
mpic_t *pic;
|
|
|
|
int i;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2005-12-15 19:41:11 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
i = VM_LONG(arg[8]);
|
2006-02-13 01:00:56 +00:00
|
|
|
if (i <= 0 || i > pluginimagearraylen)
|
2005-12-15 19:41:11 +00:00
|
|
|
return -1; // you fool
|
2006-02-13 01:00:56 +00:00
|
|
|
i = i - 1;
|
2005-12-15 19:41:11 +00:00
|
|
|
if (pluginimagearray[i].plugin != currentplug)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (pluginimagearray[i].pic)
|
|
|
|
pic = pluginimagearray[i].pic;
|
|
|
|
else if (pluginimagearray[i].picfromwad)
|
|
|
|
return 0; //wasn't loaded.
|
|
|
|
else
|
2006-01-21 00:06:49 +00:00
|
|
|
{
|
2011-03-31 01:14:01 +00:00
|
|
|
pic = R2D_SafeCachePic(pluginimagearray[i].name);
|
2006-01-21 00:06:49 +00:00
|
|
|
if (!pic)
|
|
|
|
return -1;
|
|
|
|
}
|
2005-12-15 19:41:11 +00:00
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_Image(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), pic);
|
2005-12-15 19:41:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
//x1,y1,x2,y2
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_Line(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
switch(qrenderer) //FIXME: I don't want qrenderer seen outside the refresh
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef GLQUAKE
|
2005-12-15 19:41:11 +00:00
|
|
|
case QR_OPENGL:
|
|
|
|
qglDisable(GL_TEXTURE_2D);
|
|
|
|
qglBegin(GL_LINES);
|
|
|
|
qglVertex2f(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]));
|
|
|
|
qglVertex2f(VM_FLOAT(arg[2]), VM_FLOAT(arg[3]));
|
|
|
|
qglEnd();
|
|
|
|
qglEnable(GL_TEXTURE_2D);
|
|
|
|
break;
|
|
|
|
#endif
|
2006-01-02 23:01:54 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_Character(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
int x, y;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
Font_BeginString(font_conchar, arg[0], arg[1], &x, &y);
|
|
|
|
Font_DrawChar(x, y, CON_WHITEMASK | 0xe000 | (unsigned int)arg[2]);
|
|
|
|
Font_EndString(font_conchar);
|
2005-12-15 19:41:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-03-31 01:14:01 +00:00
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_Fill(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
float x, y, width, height;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return 0;
|
2005-12-15 19:41:11 +00:00
|
|
|
x = VM_FLOAT(arg[0]);
|
|
|
|
y = VM_FLOAT(arg[1]);
|
|
|
|
width = VM_FLOAT(arg[2]);
|
|
|
|
height = VM_FLOAT(arg[3]);
|
2011-03-31 01:14:01 +00:00
|
|
|
|
|
|
|
R2D_FillBlock(x, y, width, height);
|
2005-12-15 19:41:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_ColourP(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
if (arg[0]<0 || arg[0]>255)
|
|
|
|
return false;
|
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ImagePaletteColour(arg[0], 1);
|
|
|
|
return 1;
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_Colour3f(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ImageColours(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), 1);
|
|
|
|
return 1;
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Draw_Colour4f(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ImageColours(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]));
|
|
|
|
return 1;
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_LocalSound(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
|
|
|
|
2005-12-15 19:41:11 +00:00
|
|
|
S_LocalSound(VM_POINTER(arg[0]));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_CL_GetStats(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pnum = VM_LONG(arg[0]);
|
|
|
|
unsigned int *stats = VM_POINTER(arg[1]);
|
|
|
|
int pluginstats = VM_LONG(arg[2]);
|
|
|
|
int max;
|
|
|
|
|
|
|
|
if (VM_OOB(arg[1], arg[2]*4))
|
|
|
|
return 0;
|
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
|
|
|
|
2005-12-15 19:41:11 +00:00
|
|
|
max = pluginstats;
|
|
|
|
if (max > MAX_CL_STATS)
|
|
|
|
max = MAX_CL_STATS;
|
|
|
|
for (i = 0; i < max; i++)
|
|
|
|
{ //fill stats with the right player's stats
|
2012-07-05 19:42:36 +00:00
|
|
|
stats[i] = cl.playerview[pnum].stats[i];
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
for (; i < pluginstats; i++) //plugin has too many stats (wow)
|
|
|
|
stats[i] = 0; //fill the rest.
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
2006-01-21 00:06:49 +00:00
|
|
|
#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];
|
|
|
|
} vmplugclientinfo_t;
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_GetPlayerInfo(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2006-01-21 00:06:49 +00:00
|
|
|
{
|
|
|
|
int i, pt;
|
|
|
|
vmplugclientinfo_t *out;
|
|
|
|
|
|
|
|
if (VM_OOB(arg[1], sizeof(vmplugclientinfo_t)))
|
|
|
|
return -1;
|
|
|
|
if (VM_LONG(arg[0]) < -1 || VM_LONG(arg[0] ) >= MAX_CLIENTS)
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
i = VM_LONG(arg[0]);
|
|
|
|
out = VM_POINTER(arg[1]);
|
2007-10-05 10:46:26 +00:00
|
|
|
if (out)
|
2006-01-21 00:06:49 +00:00
|
|
|
{
|
2007-10-05 10:46:26 +00:00
|
|
|
if (i == -1)
|
2006-01-21 00:06:49 +00:00
|
|
|
{
|
2007-10-05 10:46:26 +00:00
|
|
|
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));
|
2006-01-21 00:06:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pt = Cam_TrackNum(0);
|
|
|
|
if (pt < 0)
|
|
|
|
return (cl.playernum[0] == i);
|
|
|
|
else
|
|
|
|
return pt == i;
|
|
|
|
}
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_LocalPlayerNumber(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2007-02-23 00:21:33 +00:00
|
|
|
{
|
|
|
|
return cl.playernum[0];
|
|
|
|
}
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_GetServerInfo(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2007-02-23 00:21:33 +00:00
|
|
|
{
|
|
|
|
char *outptr = VM_POINTER(arg[0]);
|
2007-10-05 10:46:26 +00:00
|
|
|
unsigned int outlen = VM_LONG(arg[1]);
|
2007-02-23 00:21:33 +00:00
|
|
|
|
|
|
|
if (VM_OOB(arg[0], outlen))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Q_strncpyz(outptr, cl.serverinfo, outlen);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_SetUserInfo(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2007-02-23 00:21:33 +00:00
|
|
|
{
|
|
|
|
char *key = VM_POINTER(arg[0]);
|
|
|
|
char *value = VM_POINTER(arg[1]);
|
|
|
|
|
2010-08-14 03:17:33 +00:00
|
|
|
CL_SetInfo(0, key, value);
|
2007-02-23 00:21:33 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2005-12-15 19:41:11 +00:00
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_GetLocationName(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2007-10-05 10:46:26 +00:00
|
|
|
{
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Con_SubPrint(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
char *name = VM_POINTER(arg[0]);
|
|
|
|
char *text = VM_POINTER(arg[1]);
|
|
|
|
console_t *con;
|
2006-01-02 23:01:54 +00:00
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
|
|
|
|
2005-12-15 19:41:11 +00:00
|
|
|
con = Con_FindConsole(name);
|
|
|
|
if (!con)
|
|
|
|
{
|
2011-06-16 02:03:57 +00:00
|
|
|
con = Con_Create(name, 0);
|
2005-12-20 23:34:06 +00:00
|
|
|
Con_SetActive(con);
|
2005-12-15 19:41:11 +00:00
|
|
|
|
|
|
|
if (currentplug->conexecutecommand)
|
|
|
|
{
|
|
|
|
con->userdata = currentplug;
|
|
|
|
con->linebuffered = Plug_SubConsoleCommand;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_PrintCon(con, text);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Con_RenameSub(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-15 19:41:11 +00:00
|
|
|
{
|
|
|
|
char *name = VM_POINTER(arg[0]);
|
|
|
|
console_t *con;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
2005-12-15 19:41:11 +00:00
|
|
|
con = Con_FindConsole(name);
|
|
|
|
if (!con)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Q_strncpyz(con->name, name, sizeof(con->name));
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Con_IsActive(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-20 23:34:06 +00:00
|
|
|
{
|
|
|
|
char *name = VM_POINTER(arg[0]);
|
|
|
|
console_t *con;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
2005-12-20 23:34:06 +00:00
|
|
|
con = Con_FindConsole(name);
|
|
|
|
if (!con)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return Con_IsActive(con);
|
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Con_SetActive(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-20 23:34:06 +00:00
|
|
|
{
|
|
|
|
char *name = VM_POINTER(arg[0]);
|
|
|
|
console_t *con;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
2005-12-20 23:34:06 +00:00
|
|
|
con = Con_FindConsole(name);
|
|
|
|
if (!con)
|
2011-06-16 02:03:57 +00:00
|
|
|
con = Con_Create(name, 0);
|
2005-12-15 19:41:11 +00:00
|
|
|
|
2005-12-20 23:34:06 +00:00
|
|
|
Con_SetActive(con);
|
|
|
|
return true;
|
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Con_Destroy(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-20 23:34:06 +00:00
|
|
|
{
|
|
|
|
char *name = VM_POINTER(arg[0]);
|
|
|
|
console_t *con;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
2005-12-20 23:34:06 +00:00
|
|
|
con = Con_FindConsole(name);
|
|
|
|
if (!con)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Con_Destroy(con);
|
|
|
|
return true;
|
|
|
|
}
|
2009-07-18 20:23:00 +00:00
|
|
|
qintptr_t VARGS Plug_Con_NameForNum(void *offset, quintptr_t mask, const qintptr_t *arg)
|
2005-12-20 23:34:06 +00:00
|
|
|
{
|
|
|
|
char num = VM_LONG(arg[0]);
|
|
|
|
char *buffer = VM_POINTER(arg[1]);
|
|
|
|
int buffersize = VM_LONG(arg[2]);
|
|
|
|
if (VM_OOB(arg[1], arg[2]) || buffersize < 1)
|
|
|
|
return false;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-01-02 23:01:54 +00:00
|
|
|
return false;
|
2005-12-20 23:34:06 +00:00
|
|
|
|
|
|
|
return Con_NameForNum(num, buffer, buffersize);
|
|
|
|
}
|
2005-12-15 19:41:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Plug_Client_Init(void)
|
|
|
|
{
|
2006-01-02 23:01:54 +00:00
|
|
|
Plug_RegisterBuiltin("CL_GetStats", Plug_CL_GetStats, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Menu_Control", Plug_Menu_Control, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Key_GetKeyCode", Plug_Key_GetKeyCode, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
|
|
|
|
Plug_RegisterBuiltin("Draw_LoadImage", Plug_Draw_LoadImage, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Draw_Image", Plug_Draw_Image, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Draw_Character", Plug_Draw_Character, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Draw_Fill", Plug_Draw_Fill, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Draw_Line", Plug_Draw_Line, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Draw_Colourp", Plug_Draw_ColourP, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Draw_Colour3f", Plug_Draw_Colour3f, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Draw_Colour4f", Plug_Draw_Colour4f, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
|
|
|
|
Plug_RegisterBuiltin("Con_SubPrint", Plug_Con_SubPrint, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Con_RenameSub", Plug_Con_RenameSub, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Con_IsActive", Plug_Con_IsActive, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Con_SetActive", Plug_Con_SetActive, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Con_Destroy", Plug_Con_Destroy, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("Con_NameForNum", Plug_Con_NameForNum, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
|
|
|
|
Plug_RegisterBuiltin("LocalSound", Plug_LocalSound, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("SCR_CenterPrint", Plug_SCR_CenterPrint, PLUG_BIF_NEEDSRENDERER);
|
2006-01-21 00:06:49 +00:00
|
|
|
|
2007-10-05 10:46:26 +00:00
|
|
|
Plug_RegisterBuiltin("GetLocationName", Plug_GetLocationName, PLUG_BIF_NEEDSRENDERER);
|
2006-01-21 00:06:49 +00:00
|
|
|
Plug_RegisterBuiltin("GetPlayerInfo", Plug_GetPlayerInfo, PLUG_BIF_NEEDSRENDERER);
|
2007-02-23 00:21:33 +00:00
|
|
|
Plug_RegisterBuiltin("LocalPlayerNumber", Plug_LocalPlayerNumber, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("GetServerInfo", Plug_GetServerInfo, PLUG_BIF_NEEDSRENDERER);
|
|
|
|
Plug_RegisterBuiltin("SetUserInfo", Plug_SetUserInfo, PLUG_BIF_NEEDSRENDERER);
|
2005-12-15 19:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Plug_Client_Close(plugin_t *plug)
|
|
|
|
{
|
|
|
|
Plug_FreePlugImages(plug);
|
|
|
|
|
|
|
|
|
|
|
|
if (menuplug == plug)
|
|
|
|
{
|
|
|
|
menuplug = NULL;
|
|
|
|
key_dest = key_game;
|
|
|
|
}
|
|
|
|
if (protocolclientplugin == plug)
|
|
|
|
{
|
|
|
|
protocolclientplugin = NULL;
|
|
|
|
if (cls.protocol == CP_PLUGIN)
|
|
|
|
cls.protocol = CP_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|