--- deliantra/server/plugins/cfperl/cfperl.xs 2006/05/09 17:48:28 1.52 +++ deliantra/server/plugins/cfperl/cfperl.xs 2006/06/26 15:40:15 1.55 @@ -429,6 +429,7 @@ registerGlobalEvent (NULL, EVENT_FREE_OB, PLUGIN_NAME, globalEventListener); registerGlobalEvent (NULL, EVENT_PLAYER_LOAD, PLUGIN_NAME, globalEventListener); registerGlobalEvent (NULL, EVENT_PLAYER_SAVE, PLUGIN_NAME, globalEventListener); + registerGlobalEvent (NULL, EVENT_EXTCMD, PLUGIN_NAME, globalEventListener); char *argv[] = { "", @@ -444,6 +445,8 @@ perl = perl_alloc (); perl_construct (perl); + PL_exit_flags |= PERL_EXIT_DESTRUCT_END; + if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) { printf ("unable to initialize perl-interpreter, continuing without.\n"); @@ -544,6 +547,15 @@ PUSH_PV; break; + case EVENT_EXTCMD: + PUSH_PL; + { + char *buf = va_arg (args, char *); + int len = va_arg (args, int); + PUSHs (sv_2mortal (newSVpvn (buf, len))); + } + break; + case EVENT_CLOCK: clean_obj_cache (); break; @@ -1119,6 +1131,17 @@ const_iv (SOUND_FALL_HOLE) const_iv (SOUND_DRINK_POISON) const_iv (SOUND_CAST_SPELL_0) + + const_iv (MAP_FLUSH) + const_iv (MAP_PLAYER_UNIQUE) + const_iv (MAP_BLOCK) + const_iv (MAP_STYLE) + const_iv (MAP_OVERLAY) + + const_iv (MAP_IN_MEMORY) + const_iv (MAP_SWAPPED) + const_iv (MAP_LOADING) + const_iv (MAP_SAVING) }; for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) @@ -1165,6 +1188,7 @@ const_event (TELL) const_event (MUZZLE) const_event (KICK) + const_event (EXTCMD) //const_event (FREE_OB) }; @@ -1315,6 +1339,12 @@ PROTOTYPE: $$ C_ARGS: level, "%s", msg +char *path_combine (char *base, char *path) + PROTOTYPE: $$ + +char *path_combine_and_normalize (char *base, char *path) + PROTOTYPE: $$ + char * cf_get_maps_directory (char *path) PROTOTYPE: $ @@ -1635,6 +1665,24 @@ RETVAL = pl->next; OUTPUT: RETVAL +bool +cell_visible (player *pl, int dx, int dy) + CODE: + RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 + && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; + OUTPUT: + RETVAL + +void +send (player *pl, SV *packet) + CODE: +{ + STRLEN len; + char *buf = SvPVbyte (packet, len); + + Write_String_To_Socket (&pl->socket, buf, len); +} + int listening (player *pl, int new_value = -1) CODE: @@ -1731,17 +1779,26 @@ PROTOTYPE: $ ALIAS: map = 0 +mapstruct *has_been_loaded (char *name) + PROTOTYPE: $ + mapstruct *cf_map_get_first () PROTOTYPE: ALIAS: first = 0 # whoever "designed" the plug-in api should have wasted -# his/her time with staying away form the project - would have +# his/her time with staying away from the project - would have # saved others a lot of time, without doubt. void set_path (mapstruct *where, char *path) CODE: strcpy (where->path, path); +int in_memory (mapstruct *map) + CODE: + RETVAL = map->in_memory; + OUTPUT: + RETVAL + bool unique (mapstruct *map) CODE: RETVAL = map->unique; @@ -1759,19 +1816,39 @@ object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) C_ARGS: str, map, nx, ny -#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny) +void +cf_map_normalise (mapstruct *map, int x, int y) + PPCODE: +{ + mapstruct *nmap = 0; + I16 nx = 0, ny = 0; + int flags = cf_map_get_flags (map, &nmap, x, y, &nx, &ny); + + EXTEND (SP, 4); + PUSHs (sv_2mortal (newSViv (flags))); + + if (GIMME_V == G_ARRAY) + { + PUSHs (sv_2mortal (newSVcfapi (CFAPI_PMAP, nmap))); + PUSHs (sv_2mortal (newSViv (nx))); + PUSHs (sv_2mortal (newSViv (ny))); + } +} void -at (mapstruct *obj, unsigned int x, unsigned int y) +at (mapstruct *map, unsigned int x, unsigned int y) PROTOTYPE: $$$ - INIT: - if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_EMPTY; PPCODE: { object *o; - - for (o = GET_MAP_OB (obj, x, y); o; o = o->above) - XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); + mapstruct *nmap = 0; + I16 nx, ny; + + cf_map_get_flags (map, &nmap, x, y, &nx, &ny); + + if (nmap) + for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) + XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); } SV *