ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/plugins.c
(Generate patch)

Comparing deliantra/server/server/plugins.c (file contents):
Revision 1.5 by elmex, Wed Feb 22 18:53:56 2006 UTC vs.
Revision 1.6 by root, Mon Mar 6 22:59:26 2006 UTC

1/* 1/*
2 * static char *rcsid_plugins_c = 2 * static char *rcsid_plugins_c =
3 * "$Id: plugins.c,v 1.5 2006/02/22 18:53:56 elmex Exp $"; 3 * "$Id: plugins.c,v 1.6 2006/03/06 22:59:26 root Exp $";
4 */ 4 */
5 5
6/*****************************************************************************/ 6/*****************************************************************************/
7/* CrossFire, A Multiplayer game for X-windows */ 7/* CrossFire, A Multiplayer game for X-windows */
8/* */ 8/* */
127 127
128/*****************************************************************************/ 128/*****************************************************************************/
129/* NEW PLUGIN STUFF STARTS HERE */ 129/* NEW PLUGIN STUFF STARTS HERE */
130/*****************************************************************************/ 130/*****************************************************************************/
131 131
132static void plugin_load_original_map(mapstruct *map)
133{
134 execute_global_event (EVENT_MAPLOAD, map);
135}
136
137static void plugin_load_temporary_map(mapstruct *map)
138{
139 execute_global_event (EVENT_MAPIN, map);
140}
141
132static void plugin_object_free(object *ob) 142static void plugin_object_free(object *ob)
133{ 143{
134 execute_global_event (EVENT_FREE_OB, ob); 144 execute_global_event (EVENT_FREE_OB, ob);
135} 145}
136 146
271int execute_global_event(int eventcode, ...) 281int execute_global_event(int eventcode, ...)
272{ 282{
273 va_list args; 283 va_list args;
274 object* op; 284 object* op;
275 object* op2; 285 object* op2;
286 mapstruct *map;
276 player* pl; 287 player* pl;
277 char* buf; 288 char* buf;
278 int i, rt; 289 int i, rt;
279 crossfire_plugin* cp; 290 crossfire_plugin* cp;
280 if (plugins_list == NULL) 291 if (plugins_list == NULL)
289 case EVENT_TELL: 300 case EVENT_TELL:
290 /* no additional arguments */ 301 /* no additional arguments */
291 for (cp = plugins_list; cp != NULL; cp = cp->next) { 302 for (cp = plugins_list; cp != NULL; cp = cp->next) {
292 if (cp->gevent[eventcode] != NULL) 303 if (cp->gevent[eventcode] != NULL)
293 cp->gevent[eventcode](&rt, eventcode); 304 cp->gevent[eventcode](&rt, eventcode);
305 }
306 break;
307
308 case EVENT_MAPLOAD:
309 case EVENT_MAPOUT:
310 case EVENT_MAPIN:
311 /* map argument */
312 map = va_arg(args, mapstruct*);
313 for (cp = plugins_list; cp != NULL; cp = cp->next) {
314 if (cp->gevent[eventcode] != NULL)
315 cp->gevent[eventcode](&rt, eventcode, map);
294 } 316 }
295 break; 317 break;
296 318
297 case EVENT_REMOVE: 319 case EVENT_REMOVE:
298 case EVENT_MAPENTER: 320 case EVENT_MAPENTER:
392 f_plug_postinit closefunc; 414 f_plug_postinit closefunc;
393 int i; 415 int i;
394 crossfire_plugin* cp; 416 crossfire_plugin* cp;
395 crossfire_plugin* ccp; 417 crossfire_plugin* ccp;
396 418
419 load_original_map_callback = plugin_load_original_map;
420 load_temporary_map_callback = plugin_load_temporary_map;
397 object_free_callback = plugin_object_free; 421 object_free_callback = plugin_object_free;
398 422
399 /* Open the plugin lib and load the required functions */ 423 /* Open the plugin lib and load the required functions */
400 ptr = plugins_dlopen(libfile); 424 ptr = plugins_dlopen(libfile);
401 if (ptr == NULL) { 425 if (ptr == NULL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines