diff --git a/qw/include/Makefile.am b/qw/include/Makefile.am index 76fd00253..705770f7a 100644 --- a/qw/include/Makefile.am +++ b/qw/include/Makefile.am @@ -4,5 +4,5 @@ AUTOMAKE_OPTIONS= foreign EXTRA_DIST = \ 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 \ - crudefile.h game.h host.h msg_ucmd.h pmove.h \ - protocol.h server.h sv_demo.h sv_pr_cmds.h sv_progs.h + crudefile.h game.h host.h msg_ucmd.h pmove.h protocol.h \ + server.h sv_gib.h sv_demo.h sv_pr_cmds.h sv_progs.h diff --git a/qw/include/sv_gib.h b/qw/include/sv_gib.h new file mode 100644 index 000000000..227871c6b --- /dev/null +++ b/qw/include/sv_gib.h @@ -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; diff --git a/qw/source/sv_gib.c b/qw/source/sv_gib.c index 42758e717..839d39ae3 100644 --- a/qw/source/sv_gib.c +++ b/qw/source/sv_gib.c @@ -42,10 +42,16 @@ static __attribute__ ((unused)) const char rcsid[] = #include "QF/hash.h" #include "QF/info.h" #include "QF/gib_builtin.h" +#include "QF/gib_thread.h" #include "server.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 * SV_GIB_GetClient (int uid) { @@ -107,7 +113,14 @@ SV_GIB_Client_GetInfo_f (void) void SV_GIB_Init (void) { + // Builtins GIB_Builtin_Add ("client::getList", SV_GIB_Client_GetList_f); GIB_Builtin_Add ("client::getKeys", SV_GIB_Client_GetKeys_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"); } diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 09c3e6f07..3e7fe6e2b 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -94,6 +94,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include "server.h" #include "sv_demo.h" #include "sv_progs.h" +#include "sv_gib.h" SERVER_PLUGIN_PROTOS static plugin_list_t server_plugin_list[] = { @@ -382,6 +383,10 @@ SV_DropClient (client_t *drop) // send notification to all remaining clients 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 diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 096d8950b..bbfed26db 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -64,6 +64,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include "server.h" #include "sv_demo.h" #include "sv_progs.h" +#include "sv_gib.h" #include "world.h" typedef struct ucmd_s { @@ -94,8 +95,6 @@ cvar_t *sv_timekick_interval; cvar_t *sv_timecheck_fuzz; cvar_t *sv_timecheck_decay; -gib_event_t *sv_chat_e; - // 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, va ("fullserverinfo \"%s\"\n", 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 @@ -540,6 +543,10 @@ SV_Begin_f (ucmd_t *cmd) SVvector (ent, angles)[i]); MSG_WriteAngle (&host_client->netchan.message, 0); #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\"."); sv_kickfake = Cvar_Get ("sv_kickfake", "1", CVAR_NONE, NULL, "Kick users sending to send fake talk messages"); - sv_chat_e = GIB_Event_New ("chat"); }