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

Comparing deliantra/server/plugins/cfperl/cfperl.xs (file contents):
Revision 1.52 by root, Tue May 9 17:48:28 2006 UTC vs.
Revision 1.55 by root, Mon Jun 26 15:40:15 2006 UTC

427 registerGlobalEvent (NULL, EVENT_MUZZLE, PLUGIN_NAME, globalEventListener); 427 registerGlobalEvent (NULL, EVENT_MUZZLE, PLUGIN_NAME, globalEventListener);
428 registerGlobalEvent (NULL, EVENT_KICK, PLUGIN_NAME, globalEventListener); 428 registerGlobalEvent (NULL, EVENT_KICK, PLUGIN_NAME, globalEventListener);
429 registerGlobalEvent (NULL, EVENT_FREE_OB, PLUGIN_NAME, globalEventListener); 429 registerGlobalEvent (NULL, EVENT_FREE_OB, PLUGIN_NAME, globalEventListener);
430 registerGlobalEvent (NULL, EVENT_PLAYER_LOAD, PLUGIN_NAME, globalEventListener); 430 registerGlobalEvent (NULL, EVENT_PLAYER_LOAD, PLUGIN_NAME, globalEventListener);
431 registerGlobalEvent (NULL, EVENT_PLAYER_SAVE, PLUGIN_NAME, globalEventListener); 431 registerGlobalEvent (NULL, EVENT_PLAYER_SAVE, PLUGIN_NAME, globalEventListener);
432 registerGlobalEvent (NULL, EVENT_EXTCMD, PLUGIN_NAME, globalEventListener);
432 433
433 char *argv[] = { 434 char *argv[] = {
434 "", 435 "",
435 "-e" 436 "-e"
436 "BEGIN {" 437 "BEGIN {"
442 }; 443 };
443 444
444 perl = perl_alloc (); 445 perl = perl_alloc ();
445 perl_construct (perl); 446 perl_construct (perl);
446 447
448 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
449
447 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) 450 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl))
448 { 451 {
449 printf ("unable to initialize perl-interpreter, continuing without.\n"); 452 printf ("unable to initialize perl-interpreter, continuing without.\n");
450 453
451 perl_destruct (perl); 454 perl_destruct (perl);
540 case EVENT_SHOUT: 543 case EVENT_SHOUT:
541 case EVENT_MUZZLE: 544 case EVENT_MUZZLE:
542 case EVENT_KICK: 545 case EVENT_KICK:
543 PUSH_OB; 546 PUSH_OB;
544 PUSH_PV; 547 PUSH_PV;
548 break;
549
550 case EVENT_EXTCMD:
551 PUSH_PL;
552 {
553 char *buf = va_arg (args, char *);
554 int len = va_arg (args, int);
555 PUSHs (sv_2mortal (newSVpvn (buf, len)));
556 }
545 break; 557 break;
546 558
547 case EVENT_CLOCK: 559 case EVENT_CLOCK:
548 clean_obj_cache (); 560 clean_obj_cache ();
549 break; 561 break;
1117 const_iv (SOUND_CLOCK) 1129 const_iv (SOUND_CLOCK)
1118 const_iv (SOUND_TURN_HANDLE) 1130 const_iv (SOUND_TURN_HANDLE)
1119 const_iv (SOUND_FALL_HOLE) 1131 const_iv (SOUND_FALL_HOLE)
1120 const_iv (SOUND_DRINK_POISON) 1132 const_iv (SOUND_DRINK_POISON)
1121 const_iv (SOUND_CAST_SPELL_0) 1133 const_iv (SOUND_CAST_SPELL_0)
1134
1135 const_iv (MAP_FLUSH)
1136 const_iv (MAP_PLAYER_UNIQUE)
1137 const_iv (MAP_BLOCK)
1138 const_iv (MAP_STYLE)
1139 const_iv (MAP_OVERLAY)
1140
1141 const_iv (MAP_IN_MEMORY)
1142 const_iv (MAP_SWAPPED)
1143 const_iv (MAP_LOADING)
1144 const_iv (MAP_SAVING)
1122 }; 1145 };
1123 1146
1124 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1147 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1125 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1148 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1126 1149
1163 const_event (REMOVE) 1186 const_event (REMOVE)
1164 const_event (SHOUT) 1187 const_event (SHOUT)
1165 const_event (TELL) 1188 const_event (TELL)
1166 const_event (MUZZLE) 1189 const_event (MUZZLE)
1167 const_event (KICK) 1190 const_event (KICK)
1191 const_event (EXTCMD)
1168 //const_event (FREE_OB) 1192 //const_event (FREE_OB)
1169 }; 1193 };
1170 1194
1171 AV *av = get_av ("cf::EVENT", 1); 1195 AV *av = get_av ("cf::EVENT", 1);
1172 1196
1313void 1337void
1314LOG (int level, char *msg) 1338LOG (int level, char *msg)
1315 PROTOTYPE: $$ 1339 PROTOTYPE: $$
1316 C_ARGS: level, "%s", msg 1340 C_ARGS: level, "%s", msg
1317 1341
1342char *path_combine (char *base, char *path)
1343 PROTOTYPE: $$
1344
1345char *path_combine_and_normalize (char *base, char *path)
1346 PROTOTYPE: $$
1347
1318char * 1348char *
1319cf_get_maps_directory (char *path) 1349cf_get_maps_directory (char *path)
1320 PROTOTYPE: $ 1350 PROTOTYPE: $
1321 ALIAS: maps_directory = 0 1351 ALIAS: maps_directory = 0
1322 1352
1633player *next (player *pl) 1663player *next (player *pl)
1634 CODE: 1664 CODE:
1635 RETVAL = pl->next; 1665 RETVAL = pl->next;
1636 OUTPUT: RETVAL 1666 OUTPUT: RETVAL
1637 1667
1668bool
1669cell_visible (player *pl, int dx, int dy)
1670 CODE:
1671 RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2
1672 && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2];
1673 OUTPUT:
1674 RETVAL
1675
1676void
1677send (player *pl, SV *packet)
1678 CODE:
1679{
1680 STRLEN len;
1681 char *buf = SvPVbyte (packet, len);
1682
1683 Write_String_To_Socket (&pl->socket, buf, len);
1684}
1685
1638int 1686int
1639listening (player *pl, int new_value = -1) 1687listening (player *pl, int new_value = -1)
1640 CODE: 1688 CODE:
1641 RETVAL = pl->listening; 1689 RETVAL = pl->listening;
1642 if (new_value >= 0) 1690 if (new_value >= 0)
1729 1777
1730mapstruct *cf_map_get_map (char *name) 1778mapstruct *cf_map_get_map (char *name)
1731 PROTOTYPE: $ 1779 PROTOTYPE: $
1732 ALIAS: map = 0 1780 ALIAS: map = 0
1733 1781
1782mapstruct *has_been_loaded (char *name)
1783 PROTOTYPE: $
1784
1734mapstruct *cf_map_get_first () 1785mapstruct *cf_map_get_first ()
1735 PROTOTYPE: 1786 PROTOTYPE:
1736 ALIAS: first = 0 1787 ALIAS: first = 0
1737 1788
1738# whoever "designed" the plug-in api should have wasted 1789# whoever "designed" the plug-in api should have wasted
1739# his/her time with staying away form the project - would have 1790# his/her time with staying away from the project - would have
1740# saved others a lot of time, without doubt. 1791# saved others a lot of time, without doubt.
1741void set_path (mapstruct *where, char *path) 1792void set_path (mapstruct *where, char *path)
1742 CODE: 1793 CODE:
1743 strcpy (where->path, path); 1794 strcpy (where->path, path);
1795
1796int in_memory (mapstruct *map)
1797 CODE:
1798 RETVAL = map->in_memory;
1799 OUTPUT:
1800 RETVAL
1744 1801
1745bool unique (mapstruct *map) 1802bool unique (mapstruct *map)
1746 CODE: 1803 CODE:
1747 RETVAL = map->unique; 1804 RETVAL = map->unique;
1748 OUTPUT: 1805 OUTPUT:
1757object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) 1814object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1758 1815
1759object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) 1816object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1760 C_ARGS: str, map, nx, ny 1817 C_ARGS: str, map, nx, ny
1761 1818
1762#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1763
1764void 1819void
1820cf_map_normalise (mapstruct *map, int x, int y)
1821 PPCODE:
1822{
1823 mapstruct *nmap = 0;
1824 I16 nx = 0, ny = 0;
1825 int flags = cf_map_get_flags (map, &nmap, x, y, &nx, &ny);
1826
1827 EXTEND (SP, 4);
1828 PUSHs (sv_2mortal (newSViv (flags)));
1829
1830 if (GIMME_V == G_ARRAY)
1831 {
1832 PUSHs (sv_2mortal (newSVcfapi (CFAPI_PMAP, nmap)));
1833 PUSHs (sv_2mortal (newSViv (nx)));
1834 PUSHs (sv_2mortal (newSViv (ny)));
1835 }
1836}
1837
1838void
1765at (mapstruct *obj, unsigned int x, unsigned int y) 1839at (mapstruct *map, unsigned int x, unsigned int y)
1766 PROTOTYPE: $$$ 1840 PROTOTYPE: $$$
1767 INIT:
1768 if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_EMPTY;
1769 PPCODE: 1841 PPCODE:
1770{ 1842{
1771 object *o; 1843 object *o;
1772 1844 mapstruct *nmap = 0;
1845 I16 nx, ny;
1846
1847 cf_map_get_flags (map, &nmap, x, y, &nx, &ny);
1848
1849 if (nmap)
1773 for (o = GET_MAP_OB (obj, x, y); o; o = o->above) 1850 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above)
1774 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); 1851 XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o)));
1775} 1852}
1776 1853
1777SV * 1854SV *
1778bot_at (mapstruct *obj, unsigned int x, unsigned int y) 1855bot_at (mapstruct *obj, unsigned int x, unsigned int y)
1779 PROTOTYPE: $$$ 1856 PROTOTYPE: $$$

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines