Added client.connect, client.spawn, and client.disconnect GIB events.

This commit is contained in:
Brian Koropoff 2003-02-28 05:09:46 +00:00
parent 7f72596ab5
commit e9b117379f
5 changed files with 64 additions and 5 deletions

View File

@ -4,5 +4,5 @@ AUTOMAKE_OPTIONS= foreign
EXTRA_DIST = \ EXTRA_DIST = \
bothdefs.h cl_cam.h cl_demo.h cl_ents.h cl_input.h cl_main.h \ bothdefs.h cl_cam.h cl_demo.h cl_ents.h cl_input.h cl_main.h \
cl_parse.h cl_pred.h cl_skin.h cl_slist.h cl_tent.h client.h \ cl_parse.h cl_pred.h cl_skin.h cl_slist.h cl_tent.h client.h \
crudefile.h game.h host.h msg_ucmd.h pmove.h \ crudefile.h game.h host.h msg_ucmd.h pmove.h protocol.h \
protocol.h server.h sv_demo.h sv_pr_cmds.h sv_progs.h server.h sv_gib.h sv_demo.h sv_pr_cmds.h sv_progs.h

35
qw/include/sv_gib.h Normal file
View File

@ -0,0 +1,35 @@
/*
#FILENAME#
#DESCRIPTION#
Copyright (C) 2002 #AUTHOR#
Author: #AUTHOR#
Date: #DATE#
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
extern gib_event_t *sv_chat_e;
extern gib_event_t *sv_client_connect_e;
extern gib_event_t *sv_client_disconnect_e;
extern gib_event_t *sv_client_spawn_e;

View File

@ -42,10 +42,16 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/hash.h" #include "QF/hash.h"
#include "QF/info.h" #include "QF/info.h"
#include "QF/gib_builtin.h" #include "QF/gib_builtin.h"
#include "QF/gib_thread.h"
#include "server.h" #include "server.h"
#include "client.h" #include "client.h"
gib_event_t *sv_chat_e;
gib_event_t *sv_client_connect_e;
gib_event_t *sv_client_disconnect_e;
gib_event_t *sv_client_spawn_e;
static client_t * static client_t *
SV_GIB_GetClient (int uid) SV_GIB_GetClient (int uid)
{ {
@ -107,7 +113,14 @@ SV_GIB_Client_GetInfo_f (void)
void void
SV_GIB_Init (void) SV_GIB_Init (void)
{ {
// Builtins
GIB_Builtin_Add ("client::getList", SV_GIB_Client_GetList_f); GIB_Builtin_Add ("client::getList", SV_GIB_Client_GetList_f);
GIB_Builtin_Add ("client::getKeys", SV_GIB_Client_GetKeys_f); GIB_Builtin_Add ("client::getKeys", SV_GIB_Client_GetKeys_f);
GIB_Builtin_Add ("client::getInfo", SV_GIB_Client_GetInfo_f); GIB_Builtin_Add ("client::getInfo", SV_GIB_Client_GetInfo_f);
// Events
sv_chat_e = GIB_Event_New ("chat");
sv_client_connect_e = GIB_Event_New ("client.connect");
sv_client_disconnect_e = GIB_Event_New ("client.disconnect");
sv_client_spawn_e = GIB_Event_New ("client.spawn");
} }

View File

@ -94,6 +94,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "server.h" #include "server.h"
#include "sv_demo.h" #include "sv_demo.h"
#include "sv_progs.h" #include "sv_progs.h"
#include "sv_gib.h"
SERVER_PLUGIN_PROTOS SERVER_PLUGIN_PROTOS
static plugin_list_t server_plugin_list[] = { static plugin_list_t server_plugin_list[] = {
@ -382,6 +383,10 @@ SV_DropClient (client_t *drop)
// send notification to all remaining clients // send notification to all remaining clients
SV_FullClientUpdate (drop, &sv.reliable_datagram); SV_FullClientUpdate (drop, &sv.reliable_datagram);
// Trigger GIB event
if (sv_client_disconnect_e->func)
GIB_Event_Callback (sv_client_disconnect_e, 1, va("%u", drop->userid));
} }
int int

View File

@ -64,6 +64,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "server.h" #include "server.h"
#include "sv_demo.h" #include "sv_demo.h"
#include "sv_progs.h" #include "sv_progs.h"
#include "sv_gib.h"
#include "world.h" #include "world.h"
typedef struct ucmd_s { typedef struct ucmd_s {
@ -94,8 +95,6 @@ cvar_t *sv_timekick_interval;
cvar_t *sv_timecheck_fuzz; cvar_t *sv_timecheck_fuzz;
cvar_t *sv_timecheck_decay; cvar_t *sv_timecheck_decay;
gib_event_t *sv_chat_e;
// USER STRINGCMD EXECUTION host_client and sv_player will be valid. // USER STRINGCMD EXECUTION host_client and sv_player will be valid.
/* /*
@ -169,6 +168,10 @@ SV_New_f (ucmd_t *cmd)
MSG_WriteString (&host_client->netchan.message, MSG_WriteString (&host_client->netchan.message,
va ("fullserverinfo \"%s\"\n", va ("fullserverinfo \"%s\"\n",
Info_MakeString (svs.info, 0))); Info_MakeString (svs.info, 0)));
// Trigger GIB connection event
if (sv_client_connect_e->func)
GIB_Event_Callback (sv_client_connect_e, 1, va("%u", host_client->userid));
} }
static void static void
@ -540,6 +543,10 @@ SV_Begin_f (ucmd_t *cmd)
SVvector (ent, angles)[i]); SVvector (ent, angles)[i]);
MSG_WriteAngle (&host_client->netchan.message, 0); MSG_WriteAngle (&host_client->netchan.message, 0);
#endif #endif
// Trigger GIB events
if (sv_client_spawn_e->func)
GIB_Event_Callback (sv_client_spawn_e, 1, va("%u", host_client->userid));
} }
//============================================================================= //=============================================================================
@ -1811,5 +1818,4 @@ SV_UserInit (void)
"\"forgiven\"."); "\"forgiven\".");
sv_kickfake = Cvar_Get ("sv_kickfake", "1", CVAR_NONE, NULL, sv_kickfake = Cvar_Get ("sv_kickfake", "1", CVAR_NONE, NULL,
"Kick users sending to send fake talk messages"); "Kick users sending to send fake talk messages");
sv_chat_e = GIB_Event_New ("chat");
} }