version 1.45 | | version 1.46 |
---|
| | |
/* | | /* |
* static char *rcsid_plugins_c = | | * static char *rcsid_plugins_c = |
* "$Id: plugins.c,v 1.45 2005/10/18 16:54:31 gros Exp $"; | | * "$Id: plugins.c,v 1.46 2005/10/19 19:42:34 gros Exp $"; |
*/ | | */ |
| | |
/*****************************************************************************/ | | /*****************************************************************************/ |
| | |
| | |
#define NR_OF_HOOKS 70 | | #define NR_OF_HOOKS 70 |
| | |
hook_entry plug_hooks[NR_OF_HOOKS] = | | static const hook_entry plug_hooks[NR_OF_HOOKS] = |
{ | | { |
{cfapi_system_add_string, 0, "cfapi_system_add_string"}, | | {cfapi_system_add_string, 0, "cfapi_system_add_string"}, |
{cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, | | {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, |
| | |
for(cp=plugins_list; cp != NULL; cp=cp->next) | | for(cp=plugins_list; cp != NULL; cp=cp->next) |
{ | | { |
if (cp->gevent[eventcode]!=NULL) | | if (cp->gevent[eventcode]!=NULL) |
cp->gevent[eventcode](&rt,eventcode,op); | | cp->gevent[eventcode](&rt,eventcode); |
} | | } |
break; | | break; |
case EVENT_CRASH: | | case EVENT_CRASH: |
| | |
for(cp=plugins_list; cp != NULL; cp=cp->next) | | for(cp=plugins_list; cp != NULL; cp=cp->next) |
{ | | { |
if (cp->gevent[eventcode]!=NULL) | | if (cp->gevent[eventcode]!=NULL) |
cp->gevent[eventcode](&rt,eventcode,NULL); | | cp->gevent[eventcode](&rt,eventcode); |
} | | } |
break; | | break; |
case EVENT_MUZZLE: | | case EVENT_MUZZLE: |
| | |
return 0; | | return 0; |
} | | } |
| | |
int plugins_init_plugin(char* libfile) | | int plugins_init_plugin(const char* libfile) |
{ | | { |
LIBPTRTYPE ptr; | | LIBPTRTYPE ptr; |
f_plug_init initfunc; | | f_plug_init initfunc; |
| | |
return rv; | | return rv; |
} | | } |
| | |
int plugins_remove_plugin(char* id) | | int plugins_remove_plugin(const char* id) |
{ | | { |
crossfire_plugin* cp; | | crossfire_plugin* cp; |
| | |
| | |
| | |
for(cp=plugins_list; cp != NULL; cp=cp->next) | | for(cp=plugins_list; cp != NULL; cp=cp->next) |
{ | | { |
strcpy(buf, cp->id); | | new_draw_info_format (NDI_UNIQUE, 0, op, "%s, %s", cp->id, cp->fullname); |
strcat(buf, ", "); | | |
strcat(buf, cp->fullname); | | |
new_draw_info (NDI_UNIQUE, 0, op, buf); | | |
} | | } |
} | | } |
| | |
| | |
int ctype; | | int ctype; |
const char* str; | | const char* str; |
char* rv; | | char* rv; |
printf("create_map_path\n"); | | |
va_start(args,type); | | va_start(args,type); |
| | |
ctype = va_arg(args, int); | | ctype = va_arg(args, int); |
| | |
switch (ctype) | | switch (ctype) |
{ | | { |
case 0: | | case 0: |
printf("create_map_path:%s\n",str); | | |
rv = (char*)create_pathname(str); | | rv = (char*)create_pathname(str); |
break; | | break; |
case 1: | | case 1: |
| | |
pl = va_arg(args, player*); | | pl = va_arg(args, player*); |
direction = va_arg(args, int); | | direction = va_arg(args, int); |
va_end(args); | | va_end(args); |
rv = move_player(pl, direction); | | rv = move_player(pl->ob, direction); |
break; | | break; |
} | | } |
*type = CFAPI_INT; | | *type = CFAPI_INT; |
| | |
case CFAPI_OBJECT_PROP_MERGEABLE : | | case CFAPI_OBJECT_PROP_MERGEABLE : |
{ | | { |
object* op2; | | object* op2; |
ri = 0; | | |
op2 = va_arg(args, object*); | | op2 = va_arg(args, object*); |
ri = CAN_MERGE(op,op2); | | ri = CAN_MERGE(op,op2); |
rv = &ri; | | rv = &ri; |
| | |
case CFAPI_OBJECT_PROP_ARCH_NAME: | | case CFAPI_OBJECT_PROP_ARCH_NAME: |
rv = (char*)op->arch->name; | | rv = (char*)op->arch->name; |
*type = CFAPI_STRING; | | *type = CFAPI_STRING; |
| | break; |
case CFAPI_PLAYER_PROP_IP : | | case CFAPI_PLAYER_PROP_IP : |
rv = op->contr->socket.host; | | rv = op->contr->socket.host; |
*type = CFAPI_STRING; | | *type = CFAPI_STRING; |
| | |
object* op; | | object* op; |
sval = va_arg(args, char*); | | sval = va_arg(args, char*); |
| | |
printf("Object creation: name=%s\n", sval); | | |
| | |
op = get_archetype_by_object_name(sval); | | op = get_archetype_by_object_name(sval); |
| | |
printf("op found: %p\n", op); | | |
| | |
if (strncmp(query_name(op),ARCH_SINGULARITY, ARCH_SINGULARITY_LEN)==0) | | if (strncmp(query_name(op),ARCH_SINGULARITY, ARCH_SINGULARITY_LEN)==0) |
{ | | { |
free_object(op); | | free_object(op); |
| | |
} | | } |
else | | else |
{ | | { |
ret = check_inv_recursive(op,op); | | ret = check_inv_recursive(op,op2); |
*type = CFAPI_POBJECT; | | *type = CFAPI_POBJECT; |
} | | } |
| | |
| | |
va_start(args, type); | | va_start(args, type); |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
ttype = va_arg(args, int); | | ttype = va_arg(args, int); |
printf("Transfer in progress\n"); | | |
switch (ttype) | | switch (ttype) |
{ | | { |
case 0: | | case 0: |