version 1.33 | | version 1.34 |
---|
| | |
cf_log(llevDebug, "CFPython 2.0a init\n"); | | cf_log(llevDebug, "CFPython 2.0a init\n"); |
| | |
init_object_assoc_table(); | | init_object_assoc_table(); |
| | init_map_assoc_table(); |
| | |
Py_Initialize(); | | Py_Initialize(); |
Crossfire_ObjectType.tp_new = PyType_GenericNew; | | Crossfire_ObjectType.tp_new = PyType_GenericNew; |
| | |
registerGlobalEvent(NULL, EVENT_TELL, PLUGIN_NAME, globalEventListener); | | registerGlobalEvent(NULL, EVENT_TELL, PLUGIN_NAME, globalEventListener); |
registerGlobalEvent(NULL, EVENT_MUZZLE, PLUGIN_NAME, globalEventListener); | | registerGlobalEvent(NULL, EVENT_MUZZLE, PLUGIN_NAME, globalEventListener); |
registerGlobalEvent(NULL, EVENT_KICK, PLUGIN_NAME, globalEventListener); | | registerGlobalEvent(NULL, EVENT_KICK, PLUGIN_NAME, globalEventListener); |
| | registerGlobalEvent(NULL, EVENT_MAPUNLOAD, PLUGIN_NAME, globalEventListener); |
| | registerGlobalEvent(NULL, EVENT_MAPLOAD, PLUGIN_NAME, globalEventListener); |
| | |
scriptfile = fopen(cf_get_maps_directory("python/events/python_init.py"), "r"); | | scriptfile = fopen(cf_get_maps_directory("python/events/python_init.py"), "r"); |
if (scriptfile != NULL) { | | if (scriptfile != NULL) { |
| | |
case EVENT_MAPENTER: | | case EVENT_MAPENTER: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
| | context->who = Crossfire_Map_wrap(va_arg(args, mapstruct*)); |
snprintf(context->options, sizeof(context->options), "mapenter"); | | snprintf(context->options, sizeof(context->options), "mapenter"); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_MAPLEAVE: | | case EVENT_MAPLEAVE: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
| | context->who = Crossfire_Map_wrap(va_arg(args, mapstruct*)); |
snprintf(context->options, sizeof(context->options), "mapleave"); | | snprintf(context->options, sizeof(context->options), "mapleave"); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
| | |
snprintf(context->options, sizeof(context->options), "clock"); | | snprintf(context->options, sizeof(context->options), "clock"); |
break; | | break; |
case EVENT_MAPRESET: | | case EVENT_MAPRESET: |
buf = va_arg(args, char*); | | context->who = Crossfire_Map_wrap(va_arg(args, mapstruct*)); |
if (buf != NULL) | | |
snprintf(context->message, sizeof(context->message), "%s", buf); | | |
snprintf(context->options, sizeof(context->options), "mapreset"); | | snprintf(context->options, sizeof(context->options), "mapreset"); |
break; | | break; |
case EVENT_TELL: | | case EVENT_TELL: |
snprintf(context->options, sizeof(context->options), "tell"); | | snprintf(context->options, sizeof(context->options), "tell"); |
break; | | break; |
| | case EVENT_MAPUNLOAD: |
| | context->who = Crossfire_Map_wrap(va_arg(args, mapstruct*)); |
| | snprintf(context->options, sizeof(context->options), "mapunload"); |
| | break; |
| | case EVENT_MAPLOAD: |
| | context->who = Crossfire_Map_wrap(va_arg(args, mapstruct*)); |
| | snprintf(context->options, sizeof(context->options), "mapload"); |
| | break; |
} | | } |
va_end(args); | | va_end(args); |
context->returnvalue = 0; | | context->returnvalue = 0; |
| | |
| | |
context = popContext(); | | context = popContext(); |
rv = context->returnvalue; | | rv = context->returnvalue; |
| | |
| | /* Invalidate freed map wrapper. */ |
| | if (context->event_code == EVENT_MAPUNLOAD) |
| | Handle_Map_Unload_Hook(context->who); |
| | |
freeContext(context); | | freeContext(context); |
| | |
return &rv; | | return &rv; |