mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 06:10:56 +00:00
mindHog's qfpython patch. GIB info string event callbacks and a compile fix
for broken x11 headers.
This commit is contained in:
parent
ff5ad2ee1c
commit
460c8f7f0f
6 changed files with 62 additions and 7 deletions
|
@ -81,6 +81,8 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
#include "d_iface.h"
|
||||
#include "dga_check.h"
|
||||
|
||||
int XShmGetEventBase (Display *x); // for broken X11 headers
|
||||
|
||||
static Colormap x_cmap;
|
||||
static GC x_gc;
|
||||
|
||||
|
|
|
@ -543,9 +543,9 @@ void SV_ExecuteClientMessage (client_t *cl);
|
|||
void SV_UserInit (void);
|
||||
void SV_TogglePause (const char *msg);
|
||||
void *SV_AddUserCommand (const char *name, void (*func) (void *userdata),
|
||||
int flags,
|
||||
void *userdata,
|
||||
void (*on_free) (void *userdata));
|
||||
int flags,
|
||||
void *userdata,
|
||||
void (*on_free) (void *userdata));
|
||||
int SV_RemoveUserCommand (void *cmd);
|
||||
|
||||
//
|
||||
|
|
|
@ -36,3 +36,5 @@ extern gib_event_t *sv_client_connect_e;
|
|||
extern gib_event_t *sv_client_disconnect_e;
|
||||
extern gib_event_t *sv_client_spawn_e;
|
||||
extern gib_event_t *sv_map_e;
|
||||
extern gib_event_t *sv_frag_e;
|
||||
extern gib_event_t *sv_setinfo_e;
|
||||
|
|
|
@ -51,6 +51,8 @@ gib_event_t *sv_client_connect_e;
|
|||
gib_event_t *sv_client_disconnect_e;
|
||||
gib_event_t *sv_client_spawn_e;
|
||||
gib_event_t *sv_map_e;
|
||||
gib_event_t *sv_frag_e;
|
||||
gib_event_t *sv_setinfo_e;
|
||||
|
||||
static client_t *
|
||||
SV_GIB_GetClient (int uid)
|
||||
|
@ -174,4 +176,6 @@ SV_GIB_Init (void)
|
|||
sv_client_disconnect_e = GIB_Event_New ("client.disconnect");
|
||||
sv_client_spawn_e = GIB_Event_New ("client.spawn");
|
||||
sv_map_e = GIB_Event_New ("map");
|
||||
sv_frag_e = GIB_Event_New ("frag");
|
||||
sv_setinfo_e = GIB_Event_New ("setinfo");
|
||||
}
|
||||
|
|
|
@ -1370,6 +1370,34 @@ PF_logfrag (progs_t *pr)
|
|||
e1 = NUM_FOR_EDICT (pr, ent1);
|
||||
e2 = NUM_FOR_EDICT (pr, ent2);
|
||||
|
||||
// do gib event callback
|
||||
if (sv_frag_e->func) {
|
||||
char buf[16];
|
||||
char type1[2], type2[2];
|
||||
int u1, u2;
|
||||
|
||||
type1[1] = type2[1] = 0;
|
||||
if (e1 < 1 || e1 > MAX_CLIENTS) {
|
||||
type1[0] = 'e';
|
||||
u1 = e1;
|
||||
} else {
|
||||
type1[0] = 'c';
|
||||
u1 = svs.clients[e1 - 1].userid;
|
||||
}
|
||||
|
||||
if (e2 < 1 || e2 > MAX_CLIENTS) {
|
||||
type2[0] = 'e';
|
||||
u2 = e2;
|
||||
} else {
|
||||
type2[0] = 'c';
|
||||
u2 = svs.clients[e2 - 1].userid;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%d", u2);
|
||||
|
||||
GIB_Event_Callback (sv_frag_e, 4, type1, va ("%d", u1), type2, buf);
|
||||
}
|
||||
|
||||
if (e1 < 1 || e1 > MAX_CLIENTS || e2 < 1 || e2 > MAX_CLIENTS)
|
||||
return;
|
||||
|
||||
|
@ -1521,6 +1549,7 @@ PF_setinfokey (progs_t *pr)
|
|||
int e1 = NUM_FOR_EDICT (pr, edict);
|
||||
const char *key = P_GSTRING (pr, 1);
|
||||
const char *value = P_GSTRING (pr, 2);
|
||||
char oldval[MAX_INFO_STRING];
|
||||
|
||||
if (e1 == 0) {
|
||||
if (*value)
|
||||
|
@ -1529,10 +1558,19 @@ PF_setinfokey (progs_t *pr)
|
|||
else
|
||||
Info_RemoveKey (localinfo, key);
|
||||
} else if (e1 <= MAX_CLIENTS) {
|
||||
strcpy(oldval, Info_ValueForKey (svs.clients[e1 - 1].userinfo, key));
|
||||
Info_SetValueForKey (svs.clients[e1 - 1].userinfo, key, value,
|
||||
!sv_highchars->int_val);
|
||||
SV_ExtractFromUserinfo (&svs.clients[e1 - 1]);
|
||||
|
||||
// trigger a GIB event
|
||||
if (sv_setinfo_e->func)
|
||||
GIB_Event_Callback (sv_setinfo_e, 4,
|
||||
va("%d", svs.clients[e1 - 1].userid),
|
||||
key, oldval,
|
||||
Info_ValueForKey (svs.clients[e1 - 1].userinfo,
|
||||
key));
|
||||
|
||||
if (Info_FilterForKey (key, client_info_filters)) {
|
||||
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
||||
MSG_WriteByte (&sv.reliable_datagram, e1 - 1);
|
||||
|
@ -1540,6 +1578,7 @@ PF_setinfokey (progs_t *pr)
|
|||
MSG_WriteString (&sv.reliable_datagram,
|
||||
Info_ValueForKey (svs.clients[e1 - 1].userinfo,
|
||||
key));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1081,6 +1081,8 @@ SV_Msg_f (void *unused)
|
|||
static void
|
||||
SV_SetInfo_f (void *unused)
|
||||
{
|
||||
char oldval[MAX_INFO_STRING];
|
||||
|
||||
if (Cmd_Argc () == 1) {
|
||||
SV_Printf ("User info settings:\n");
|
||||
Info_Print (host_client->userinfo);
|
||||
|
@ -1095,6 +1097,9 @@ SV_SetInfo_f (void *unused)
|
|||
if (Cmd_Argv (1)[0] == '*')
|
||||
return; // don't set priveledged values
|
||||
|
||||
// preserve the old value
|
||||
strcpy (oldval, Info_ValueForKey (host_client->userinfo,
|
||||
Cmd_Argv (1)));
|
||||
|
||||
if (UserInfoCallback) {
|
||||
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
|
||||
|
@ -1103,10 +1108,6 @@ SV_SetInfo_f (void *unused)
|
|||
PR_ExecuteProgram (&sv_pr_state, UserInfoCallback);
|
||||
return;
|
||||
} else {
|
||||
char oldval[MAX_INFO_STRING];
|
||||
|
||||
strcpy (oldval, Info_ValueForKey (host_client->userinfo,
|
||||
Cmd_Argv (1)));
|
||||
Info_SetValueForKey (host_client->userinfo, Cmd_Argv (1), Cmd_Argv (2),
|
||||
!sv_highchars->int_val);
|
||||
if (strequal
|
||||
|
@ -1117,6 +1118,13 @@ SV_SetInfo_f (void *unused)
|
|||
// process any changed values
|
||||
SV_ExtractFromUserinfo (host_client);
|
||||
|
||||
// trigger a GIB event
|
||||
if (sv_setinfo_e->func)
|
||||
GIB_Event_Callback (sv_setinfo_e, 4, va("%d", host_client->userid),
|
||||
Cmd_Argv (1), oldval,
|
||||
Info_ValueForKey (host_client->userinfo,
|
||||
Cmd_Argv (1)));
|
||||
|
||||
if (Info_FilterForKey (Cmd_Argv (1), client_info_filters)) {
|
||||
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
|
||||
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
|
||||
|
|
Loading…
Reference in a new issue