… | |
… | |
99 | *stash_cf_arch_wrap, |
99 | *stash_cf_arch_wrap, |
100 | *stash_cf_party_wrap, |
100 | *stash_cf_party_wrap, |
101 | *stash_cf_region_wrap, |
101 | *stash_cf_region_wrap, |
102 | *stash_cf_living_wrap; |
102 | *stash_cf_living_wrap; |
103 | |
103 | |
|
|
104 | static inline SV * |
|
|
105 | newSVpv_utf8 (const char *s) |
|
|
106 | { |
|
|
107 | SV *sv = newSVpv (s, 0); |
|
|
108 | SvUTF8_on (sv); |
|
|
109 | return sv; |
|
|
110 | } |
|
|
111 | |
|
|
112 | static inline SV * |
|
|
113 | newSVpvn_utf8 (const char *s, STRLEN l) |
|
|
114 | { |
|
|
115 | SV *sv = newSVpvn (s, l); |
|
|
116 | SvUTF8_on (sv); |
|
|
117 | return sv; |
|
|
118 | } |
|
|
119 | |
104 | // helper cast function, returns super class * or 0 |
120 | // helper cast function, returns super class * or 0 |
105 | template<class super> |
121 | template<class super> |
106 | static super * |
122 | static super * |
107 | is_a (attachable *at) |
123 | is_a (attachable *at) |
108 | { |
124 | { |
… | |
… | |
247 | } |
263 | } |
248 | } |
264 | } |
249 | } |
265 | } |
250 | |
266 | |
251 | void |
267 | void |
252 | attachable::set_key (const char *key, const char *value) |
268 | attachable::set_key (const char *key, const char *value, bool is_utf8) |
253 | { |
269 | { |
254 | if (!self) |
270 | if (!self) |
255 | self = newHV (); |
271 | self = newHV (); |
256 | |
272 | |
257 | if (value) |
273 | if (value) |
258 | hv_store (self, key, strlen (key), newSVpv (value, 0), 0); |
274 | hv_store (self, key, strlen (key), is_utf8 ? newSVpv_utf8 (value) : newSVpv (value, 0), 0); |
259 | else |
275 | else |
260 | hv_delete (self, key, strlen (key), G_DISCARD); |
276 | hv_delete (self, key, strlen (key), G_DISCARD); |
261 | } |
277 | } |
262 | |
278 | |
263 | attachable & |
279 | attachable & |
… | |
… | |
394 | { |
410 | { |
395 | if (SvOK (sv)) |
411 | if (SvOK (sv)) |
396 | return SvPTR (sv, klass); |
412 | return SvPTR (sv, klass); |
397 | else |
413 | else |
398 | return 0; |
414 | return 0; |
399 | } |
|
|
400 | |
|
|
401 | static inline SV * |
|
|
402 | newSVpv_utf8 (const char *s) |
|
|
403 | { |
|
|
404 | SV *sv = newSVpv (s, 0); |
|
|
405 | SvUTF8_on (sv); |
|
|
406 | return sv; |
|
|
407 | } |
|
|
408 | |
|
|
409 | static inline SV * |
|
|
410 | newSVpvn_utf8 (const char *s, STRLEN l) |
|
|
411 | { |
|
|
412 | SV *sv = newSVpvn (s, l); |
|
|
413 | SvUTF8_on (sv); |
|
|
414 | return sv; |
|
|
415 | } |
415 | } |
416 | |
416 | |
417 | inline SV *to_sv (const shstr & v) { return v ? newSVpvn_utf8 ((const char *)v, v.length ()) : &PL_sv_undef; } |
417 | inline SV *to_sv (const shstr & v) { return v ? newSVpvn_utf8 ((const char *)v, v.length ()) : &PL_sv_undef; } |
418 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
418 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
419 | inline SV *to_sv (bool v) { return newSViv (v); } |
419 | inline SV *to_sv (bool v) { return newSViv (v); } |
… | |
… | |
1021 | void |
1021 | void |
1022 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
1022 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
1023 | { |
1023 | { |
1024 | CALL_BEGIN (4); |
1024 | CALL_BEGIN (4); |
1025 | CALL_ARG (ns); |
1025 | CALL_ARG (ns); |
1026 | CALL_ARG (color); |
|
|
1027 | CALL_ARG (type); |
1026 | CALL_ARG (type); |
1028 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
1027 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
|
|
1028 | CALL_ARG (color); |
1029 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1029 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1030 | CALL_END; |
1030 | CALL_END; |
1031 | } |
1031 | } |
1032 | |
1032 | |
1033 | int |
1033 | int |
… | |
… | |
1043 | CALL_END; |
1043 | CALL_END; |
1044 | |
1044 | |
1045 | return can; |
1045 | return can; |
1046 | } |
1046 | } |
1047 | |
1047 | |
|
|
1048 | player * |
|
|
1049 | player::find (const char *name) |
|
|
1050 | { |
|
|
1051 | CALL_BEGIN (1); |
|
|
1052 | CALL_ARG (name); |
|
|
1053 | CALL_CALL ("cf::player::find", G_SCALAR); |
|
|
1054 | |
|
|
1055 | player *retval; |
|
|
1056 | |
|
|
1057 | if (count) |
|
|
1058 | sv_to (POPs, retval); |
|
|
1059 | else |
|
|
1060 | retval = 0; |
|
|
1061 | |
|
|
1062 | CALL_END; |
|
|
1063 | |
|
|
1064 | return retval; |
|
|
1065 | } |
|
|
1066 | |
1048 | maptile * |
1067 | maptile * |
1049 | maptile::find_sync (const char *path, maptile *origin) |
1068 | maptile::find_sync (const char *path, maptile *origin) |
1050 | { |
1069 | { |
1051 | CALL_BEGIN (2); |
1070 | CALL_BEGIN (2); |
1052 | CALL_ARG (path); |
1071 | CALL_ARG (path); |
… | |
… | |
1064 | |
1083 | |
1065 | return retval; |
1084 | return retval; |
1066 | } |
1085 | } |
1067 | |
1086 | |
1068 | maptile * |
1087 | maptile * |
1069 | maptile::find_async (const char *path, maptile *origin) |
1088 | maptile::find_async (const char *path, maptile *origin, bool load) |
1070 | { |
1089 | { |
1071 | CALL_BEGIN (2); |
1090 | CALL_BEGIN (3); |
1072 | CALL_ARG (path); |
1091 | CALL_ARG (path); |
1073 | CALL_ARG (origin); |
1092 | CALL_ARG (origin); |
|
|
1093 | CALL_ARG (load); |
1074 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1094 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1075 | |
1095 | |
1076 | maptile *retval; |
1096 | maptile *retval; |
1077 | |
1097 | |
1078 | if (count) |
1098 | if (count) |
… | |
… | |
1376 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1396 | const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) |
1377 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1397 | const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) |
1378 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1398 | const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) |
1379 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_CLIENT_SENT) const_iv (FLAG_BERSERK) |
1399 | const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_CLIENT_SENT) const_iv (FLAG_BERSERK) |
1380 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1400 | const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) |
1381 | const_iv (FLAG_OBJ_SAVE_ON_OVL) const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) |
1401 | const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) |
1382 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1402 | const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) |
1383 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1403 | const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) |
1384 | |
1404 | |
1385 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1405 | const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) |
1386 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
1406 | const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) |
1387 | const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD) |
1407 | const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD) |
1388 | const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE) |
1408 | const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE) |
|
|
1409 | const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK) |
1389 | const_iv (NDI_ALL) |
1410 | const_iv (NDI_NOCREATE) |
1390 | |
1411 | |
1391 | const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) |
1412 | const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) |
1392 | const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) |
1413 | const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) |
1393 | |
1414 | |
1394 | const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) |
1415 | const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) |
… | |
… | |
1521 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1542 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1522 | |
1543 | |
1523 | const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) |
1544 | const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) |
1524 | const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV) |
1545 | const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV) |
1525 | const_iv (GT_MINIMAL) |
1546 | const_iv (GT_MINIMAL) |
|
|
1547 | |
|
|
1548 | const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) |
|
|
1549 | const_iv (FT_RSRC) const_iv (FT_NUM) |
1526 | }; |
1550 | }; |
1527 | |
1551 | |
1528 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1552 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1529 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1553 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1530 | |
1554 | |
… | |
… | |
1564 | |
1588 | |
1565 | for_all_objects (op) |
1589 | for_all_objects (op) |
1566 | op->reattach (); |
1590 | op->reattach (); |
1567 | } |
1591 | } |
1568 | |
1592 | |
1569 | void _post_tick () |
|
|
1570 | CODE: |
|
|
1571 | coroapi::next_cede = SvNV (sv_next_tick) - TICK * (1. - 1. / CEDES_PER_TICK); |
|
|
1572 | |
|
|
1573 | # support function for map-world.ext |
1593 | # support function for map-world.ext |
1574 | void _quantise (SV *data_sv, SV *plt_sv) |
1594 | void _quantise (SV *data_sv, SV *plt_sv) |
1575 | CODE: |
1595 | CODE: |
1576 | { |
1596 | { |
1577 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
1597 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
… | |
… | |
1609 | len -= 3; |
1629 | len -= 3; |
1610 | } |
1630 | } |
1611 | |
1631 | |
1612 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1632 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1613 | } |
1633 | } |
|
|
1634 | |
|
|
1635 | void _post_tick () |
|
|
1636 | CODE: |
|
|
1637 | coroapi::next_cede = SvNV (sv_next_tick) - TICK * (1. - 1. / CEDES_PER_TICK); |
|
|
1638 | |
|
|
1639 | NV till_cede () |
|
|
1640 | CODE: |
|
|
1641 | RETVAL = coroapi::next_cede - now (); |
|
|
1642 | OUTPUT: |
|
|
1643 | RETVAL |
|
|
1644 | |
|
|
1645 | NV till_tick () |
|
|
1646 | CODE: |
|
|
1647 | RETVAL = SvNV (sv_next_tick) - now (); |
|
|
1648 | OUTPUT: |
|
|
1649 | RETVAL |
1614 | |
1650 | |
1615 | NV floor (NV x) |
1651 | NV floor (NV x) |
1616 | |
1652 | |
1617 | NV ceil (NV x) |
1653 | NV ceil (NV x) |
1618 | |
1654 | |
… | |
… | |
1661 | octet_string path_combine (octet_string base, octet_string path) |
1697 | octet_string path_combine (octet_string base, octet_string path) |
1662 | PROTOTYPE: $$ |
1698 | PROTOTYPE: $$ |
1663 | |
1699 | |
1664 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1700 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1665 | PROTOTYPE: $$ |
1701 | PROTOTYPE: $$ |
1666 | |
|
|
1667 | const_octet_string |
|
|
1668 | get_maps_directory (octet_string path) |
|
|
1669 | PROTOTYPE: $ |
|
|
1670 | ALIAS: maps_directory = 0 |
|
|
1671 | CODE: |
|
|
1672 | RETVAL = create_pathname (path); |
|
|
1673 | OUTPUT: RETVAL |
|
|
1674 | |
1702 | |
1675 | void |
1703 | void |
1676 | sub_generation_inc () |
1704 | sub_generation_inc () |
1677 | CODE: |
1705 | CODE: |
1678 | PL_sub_generation++; |
1706 | PL_sub_generation++; |
… | |
… | |
1800 | #object *mortals (U32 index) |
1828 | #object *mortals (U32 index) |
1801 | # CODE: |
1829 | # CODE: |
1802 | # RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0; |
1830 | # RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0; |
1803 | # OUTPUT: RETVAL |
1831 | # OUTPUT: RETVAL |
1804 | |
1832 | |
1805 | INCLUDE: $PERL $srcdir/genacc attachable ../include/cfperl.h | |
1833 | INCLUDE: $PERL $srcdir/genacc attachable ../include/util.h ../include/cfperl.h | |
1806 | |
1834 | |
1807 | MODULE = cf PACKAGE = cf::global |
1835 | MODULE = cf PACKAGE = cf::global |
1808 | |
1836 | |
1809 | int invoke (SV *klass, int event, ...) |
1837 | int invoke (SV *klass, int event, ...) |
1810 | CODE: |
1838 | CODE: |
… | |
… | |
2136 | pl->orig_stats = pl->ob->stats; |
2164 | pl->orig_stats = pl->ob->stats; |
2137 | |
2165 | |
2138 | void clear_los (player *pl) |
2166 | void clear_los (player *pl) |
2139 | |
2167 | |
2140 | void cf_player_move (player *pl, int dir) |
2168 | void cf_player_move (player *pl, int dir) |
2141 | |
|
|
2142 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
|
|
2143 | |
2169 | |
2144 | bool |
2170 | bool |
2145 | cell_visible (player *pl, int dx, int dy) |
2171 | cell_visible (player *pl, int dx, int dy) |
2146 | CODE: |
2172 | CODE: |
2147 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
2173 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
… | |
… | |
2326 | } |
2352 | } |
2327 | } |
2353 | } |
2328 | |
2354 | |
2329 | op->destroy (); |
2355 | op->destroy (); |
2330 | } |
2356 | } |
2331 | |
|
|
2332 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
|
|
2333 | |
2357 | |
2334 | int out_of_map (maptile *map, int x, int y) |
2358 | int out_of_map (maptile *map, int x, int y) |
2335 | |
2359 | |
2336 | void |
2360 | void |
2337 | trigger (maptile *map, long connection, bool state = true) |
2361 | trigger (maptile *map, long connection, bool state = true) |
… | |
… | |
2609 | char *buf = SvPVbyte (packet, len); |
2633 | char *buf = SvPVbyte (packet, len); |
2610 | |
2634 | |
2611 | THIS->send_packet (buf, len); |
2635 | THIS->send_packet (buf, len); |
2612 | } |
2636 | } |
2613 | |
2637 | |
|
|
2638 | faceidx |
|
|
2639 | client::need_face (utf8_string name, int pri = 0) |
|
|
2640 | CODE: |
|
|
2641 | RETVAL = face_find (name, 0); |
|
|
2642 | if (RETVAL) |
|
|
2643 | { |
|
|
2644 | THIS->send_face (RETVAL, pri); |
|
|
2645 | THIS->flush_fx (); |
|
|
2646 | } |
|
|
2647 | OUTPUT: |
|
|
2648 | RETVAL |
|
|
2649 | |
|
|
2650 | int |
|
|
2651 | client::fx_want (int idx, int value = -1) |
|
|
2652 | CODE: |
|
|
2653 | if (0 < idx && idx < FT_NUM) |
|
|
2654 | { |
|
|
2655 | RETVAL = THIS->fx_want [idx]; |
|
|
2656 | if (items > 2) |
|
|
2657 | THIS->fx_want [idx] = value; |
|
|
2658 | } |
|
|
2659 | else |
|
|
2660 | RETVAL = 0; |
|
|
2661 | OUTPUT: |
|
|
2662 | RETVAL |
|
|
2663 | |
|
|
2664 | MODULE = cf PACKAGE = cf::sound PREFIX = sound_ |
|
|
2665 | |
|
|
2666 | faceidx sound_find (utf8_string name) |
|
|
2667 | |
|
|
2668 | void sound_set (utf8_string str, faceidx face) |
|
|
2669 | |
|
|
2670 | # dire hack |
|
|
2671 | void old_sound_index (int idx, faceidx face) |
|
|
2672 | CODE: |
|
|
2673 | extern faceidx old_sound_index [SOUND_CAST_SPELL_0]; |
|
|
2674 | old_sound_index [idx] = face; |
|
|
2675 | |
2614 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2676 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2615 | |
2677 | |
2616 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2678 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2617 | |
2679 | |
2618 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2680 | faceidx face_find (utf8_string name, faceidx defidx = 0) |