… | |
… | |
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 | { |
… | |
… | |
246 | delete obj; |
262 | delete obj; |
247 | } |
263 | } |
248 | } |
264 | } |
249 | } |
265 | } |
250 | |
266 | |
|
|
267 | void |
|
|
268 | attachable::set_key (const char *key, const char *value, bool is_utf8) |
|
|
269 | { |
|
|
270 | if (!self) |
|
|
271 | self = newHV (); |
|
|
272 | |
|
|
273 | if (value) |
|
|
274 | hv_store (self, key, strlen (key), is_utf8 ? newSVpv_utf8 (value) : newSVpv (value, 0), 0); |
|
|
275 | else |
|
|
276 | hv_delete (self, key, strlen (key), G_DISCARD); |
|
|
277 | } |
|
|
278 | |
251 | attachable & |
279 | attachable & |
252 | attachable::operator =(const attachable &src) |
280 | attachable::operator =(const attachable &src) |
253 | { |
281 | { |
254 | //if (self || cb) |
282 | //if (self || cb) |
255 | //INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
283 | //INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
… | |
… | |
330 | { |
358 | { |
331 | if (!obj) |
359 | if (!obj) |
332 | return &PL_sv_undef; |
360 | return &PL_sv_undef; |
333 | |
361 | |
334 | if (!obj->self) |
362 | if (!obj->self) |
|
|
363 | obj->self = newHV (); |
|
|
364 | |
|
|
365 | if (!SvOBJECT (obj->self)) |
335 | { |
366 | { |
336 | obj->self = newHV (); |
|
|
337 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
367 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
338 | |
368 | |
339 | // now bless the object _once_ |
369 | // now bless the object _once_ |
|
|
370 | //TODO: create a class registry with c++ type<=>perl name<=>stash and use it here and elsewhere |
340 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
371 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
341 | } |
372 | } |
342 | else |
373 | else |
343 | { |
374 | { |
344 | SV *sv = newRV_inc ((SV *)obj->self); |
375 | SV *sv = newRV_inc ((SV *)obj->self); |
… | |
… | |
379 | { |
410 | { |
380 | if (SvOK (sv)) |
411 | if (SvOK (sv)) |
381 | return SvPTR (sv, klass); |
412 | return SvPTR (sv, klass); |
382 | else |
413 | else |
383 | return 0; |
414 | return 0; |
384 | } |
|
|
385 | |
|
|
386 | static inline SV * |
|
|
387 | newSVpv_utf8 (const char *s) |
|
|
388 | { |
|
|
389 | SV *sv = newSVpv (s, 0); |
|
|
390 | SvUTF8_on (sv); |
|
|
391 | return sv; |
|
|
392 | } |
|
|
393 | |
|
|
394 | static inline SV * |
|
|
395 | newSVpvn_utf8 (const char *s, STRLEN l) |
|
|
396 | { |
|
|
397 | SV *sv = newSVpvn (s, l); |
|
|
398 | SvUTF8_on (sv); |
|
|
399 | return sv; |
|
|
400 | } |
415 | } |
401 | |
416 | |
402 | 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; } |
403 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
418 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
404 | inline SV *to_sv (bool v) { return newSViv (v); } |
419 | inline SV *to_sv (bool v) { return newSViv (v); } |
… | |
… | |
417 | inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
432 | inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
418 | inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
433 | inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
419 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
434 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
420 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
435 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
421 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
436 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
|
|
437 | inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
422 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
438 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
423 | inline SV *to_sv (region * v) { return newSVptr (v, stash_cf_region_wrap); } |
|
|
424 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
439 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
425 | |
440 | |
426 | inline SV *to_sv (object & v) { return to_sv (&v); } |
441 | inline SV *to_sv (object & v) { return to_sv (&v); } |
427 | inline SV *to_sv (living & v) { return to_sv (&v); } |
442 | inline SV *to_sv (living & v) { return to_sv (&v); } |
428 | |
443 | |
… | |
… | |
454 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
469 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
455 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
470 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
456 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
471 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
457 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
472 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
458 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
473 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
474 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
459 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
475 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
460 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
476 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
461 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
|
|
462 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
477 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
463 | |
478 | |
464 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
479 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
465 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
480 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
466 | |
481 | |
… | |
… | |
949 | } |
964 | } |
950 | |
965 | |
951 | SV * |
966 | SV * |
952 | cfperl_result (int idx) |
967 | cfperl_result (int idx) |
953 | { |
968 | { |
954 | AV *av = get_av ("cfperl::invoke_results", 0); |
969 | AV *av = get_av ("cf::INVOKE_RESULTS", 0); |
955 | if (!av) |
970 | if (!av) |
956 | return &PL_sv_undef; |
971 | return &PL_sv_undef; |
957 | |
972 | |
958 | SV **sv = av_fetch (av, idx, 0); |
973 | SV **sv = av_fetch (av, idx, 0); |
959 | if (!sv) |
974 | if (!sv) |
… | |
… | |
1006 | void |
1021 | void |
1007 | 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) |
1008 | { |
1023 | { |
1009 | CALL_BEGIN (4); |
1024 | CALL_BEGIN (4); |
1010 | CALL_ARG (ns); |
1025 | CALL_ARG (ns); |
1011 | CALL_ARG (color); |
|
|
1012 | CALL_ARG (type); |
1026 | CALL_ARG (type); |
1013 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
1027 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
|
|
1028 | CALL_ARG (color); |
1014 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1029 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1015 | CALL_END; |
1030 | CALL_END; |
|
|
1031 | } |
|
|
1032 | |
|
|
1033 | int |
|
|
1034 | cfperl_can_merge (object *ob1, object *ob2) |
|
|
1035 | { |
|
|
1036 | int can; |
|
|
1037 | |
|
|
1038 | CALL_BEGIN (2); |
|
|
1039 | CALL_ARG (ob1); |
|
|
1040 | CALL_ARG (ob2); |
|
|
1041 | CALL_CALL ("cf::_can_merge", G_SCALAR); |
|
|
1042 | can = count && SvTRUE (TOPs); |
|
|
1043 | CALL_END; |
|
|
1044 | |
|
|
1045 | return can; |
|
|
1046 | } |
|
|
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; |
1016 | } |
1065 | } |
1017 | |
1066 | |
1018 | maptile * |
1067 | maptile * |
1019 | maptile::find_sync (const char *path, maptile *origin) |
1068 | maptile::find_sync (const char *path, maptile *origin) |
1020 | { |
1069 | { |
… | |
… | |
1034 | |
1083 | |
1035 | return retval; |
1084 | return retval; |
1036 | } |
1085 | } |
1037 | |
1086 | |
1038 | maptile * |
1087 | maptile * |
1039 | maptile::find_async (const char *path, maptile *origin) |
1088 | maptile::find_async (const char *path, maptile *origin, bool load) |
1040 | { |
1089 | { |
1041 | CALL_BEGIN (2); |
1090 | CALL_BEGIN (3); |
1042 | CALL_ARG (path); |
1091 | CALL_ARG (path); |
1043 | CALL_ARG (origin); |
1092 | CALL_ARG (origin); |
|
|
1093 | CALL_ARG (load); |
1044 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1094 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1045 | |
1095 | |
1046 | maptile *retval; |
1096 | maptile *retval; |
1047 | |
1097 | |
1048 | if (count) |
1098 | if (count) |
… | |
… | |
1346 | 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) |
1347 | 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) |
1348 | 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) |
1349 | 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) |
1350 | 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) |
1351 | 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) |
1352 | 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) |
1353 | 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) |
1354 | |
1404 | |
1355 | 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) |
1356 | 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) |
1357 | 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) |
1358 | 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) |
1359 | const_iv (NDI_ALL) |
1410 | const_iv (NDI_NOCREATE) |
1360 | |
1411 | |
1361 | 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) |
1362 | 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) |
1363 | |
1414 | |
1364 | 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) |
… | |
… | |
1491 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1542 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1492 | |
1543 | |
1493 | 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) |
1494 | 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) |
1495 | 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) |
1496 | }; |
1550 | }; |
1497 | |
1551 | |
1498 | 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; ) |
1499 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1553 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1500 | |
1554 | |
… | |
… | |
1534 | |
1588 | |
1535 | for_all_objects (op) |
1589 | for_all_objects (op) |
1536 | op->reattach (); |
1590 | op->reattach (); |
1537 | } |
1591 | } |
1538 | |
1592 | |
1539 | void _post_tick () |
|
|
1540 | CODE: |
|
|
1541 | coroapi::next_cede = SvNV (sv_next_tick) - TICK * (1. - 1. / CEDES_PER_TICK); |
|
|
1542 | |
|
|
1543 | # support function for map-world.ext |
1593 | # support function for map-world.ext |
1544 | void _quantise (SV *data_sv, SV *plt_sv) |
1594 | void _quantise (SV *data_sv, SV *plt_sv) |
1545 | CODE: |
1595 | CODE: |
1546 | { |
1596 | { |
1547 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
1597 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
… | |
… | |
1579 | len -= 3; |
1629 | len -= 3; |
1580 | } |
1630 | } |
1581 | |
1631 | |
1582 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1632 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1583 | } |
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 |
1584 | |
1650 | |
1585 | NV floor (NV x) |
1651 | NV floor (NV x) |
1586 | |
1652 | |
1587 | NV ceil (NV x) |
1653 | NV ceil (NV x) |
1588 | |
1654 | |
… | |
… | |
1631 | octet_string path_combine (octet_string base, octet_string path) |
1697 | octet_string path_combine (octet_string base, octet_string path) |
1632 | PROTOTYPE: $$ |
1698 | PROTOTYPE: $$ |
1633 | |
1699 | |
1634 | 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) |
1635 | PROTOTYPE: $$ |
1701 | PROTOTYPE: $$ |
1636 | |
|
|
1637 | const_octet_string |
|
|
1638 | get_maps_directory (octet_string path) |
|
|
1639 | PROTOTYPE: $ |
|
|
1640 | ALIAS: maps_directory = 0 |
|
|
1641 | CODE: |
|
|
1642 | RETVAL = create_pathname (path); |
|
|
1643 | OUTPUT: RETVAL |
|
|
1644 | |
1702 | |
1645 | void |
1703 | void |
1646 | sub_generation_inc () |
1704 | sub_generation_inc () |
1647 | CODE: |
1705 | CODE: |
1648 | PL_sub_generation++; |
1706 | PL_sub_generation++; |
… | |
… | |
1770 | #object *mortals (U32 index) |
1828 | #object *mortals (U32 index) |
1771 | # CODE: |
1829 | # CODE: |
1772 | # RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0; |
1830 | # RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0; |
1773 | # OUTPUT: RETVAL |
1831 | # OUTPUT: RETVAL |
1774 | |
1832 | |
1775 | INCLUDE: $PERL $srcdir/genacc attachable ../include/cfperl.h | |
1833 | INCLUDE: $PERL $srcdir/genacc attachable ../include/util.h ../include/cfperl.h | |
1776 | |
1834 | |
1777 | MODULE = cf PACKAGE = cf::global |
1835 | MODULE = cf PACKAGE = cf::global |
1778 | |
1836 | |
1779 | int invoke (SV *klass, int event, ...) |
1837 | int invoke (SV *klass, int event, ...) |
1780 | CODE: |
1838 | CODE: |
… | |
… | |
1994 | |
2052 | |
1995 | void add_button_link (object *button, maptile *map, int connected); |
2053 | void add_button_link (object *button, maptile *map, int connected); |
1996 | |
2054 | |
1997 | void remove_button_link (object *op); |
2055 | void remove_button_link (object *op); |
1998 | |
2056 | |
|
|
2057 | void handle_apply_yield (object *op); |
|
|
2058 | |
1999 | |
2059 | |
2000 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2060 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2001 | |
2061 | |
2002 | object *cf_insert_ob_in_ob (object *ob, object *where) |
2062 | object *cf_insert_ob_in_ob (object *ob, object *where) |
2003 | |
2063 | |
… | |
… | |
2104 | pl->orig_stats = pl->ob->stats; |
2164 | pl->orig_stats = pl->ob->stats; |
2105 | |
2165 | |
2106 | void clear_los (player *pl) |
2166 | void clear_los (player *pl) |
2107 | |
2167 | |
2108 | void cf_player_move (player *pl, int dir) |
2168 | void cf_player_move (player *pl, int dir) |
2109 | |
|
|
2110 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
|
|
2111 | |
2169 | |
2112 | bool |
2170 | bool |
2113 | cell_visible (player *pl, int dx, int dy) |
2171 | cell_visible (player *pl, int dx, int dy) |
2114 | CODE: |
2172 | CODE: |
2115 | 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 |
… | |
… | |
2254 | palette = SvRV (palette); |
2312 | palette = SvRV (palette); |
2255 | |
2313 | |
2256 | STRLEN idxlen; |
2314 | STRLEN idxlen; |
2257 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2315 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2258 | |
2316 | |
2259 | region **regionmap = (region **)malloc ( |
2317 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2260 | (av_len ((AV *)palette) + 1) * sizeof (region *)); |
|
|
2261 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
2318 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
2262 | |
2319 | |
2263 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2320 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2264 | regionmap [i] = region::find ( |
2321 | regionmap [i] = region::find (SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
2265 | SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
|
|
2266 | |
2322 | |
2267 | for (int y = 0; y < THIS->height; ++y) |
2323 | for (int y = 0; y < THIS->height; ++y) |
2268 | memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width); |
2324 | memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width); |
2269 | |
2325 | |
2270 | sfree (THIS->regions, THIS->size ()); |
2326 | sfree (THIS->regions, THIS->size ()); |
2271 | free (THIS->regionmap); |
2327 | delete [] THIS->regionmap; |
2272 | |
2328 | |
2273 | THIS->regions = regions; |
2329 | THIS->regions = regions; |
2274 | THIS->regionmap = regionmap; |
2330 | THIS->regionmap = regionmap; |
2275 | } |
2331 | } |
2276 | |
2332 | |
… | |
… | |
2296 | } |
2352 | } |
2297 | } |
2353 | } |
2298 | |
2354 | |
2299 | op->destroy (); |
2355 | op->destroy (); |
2300 | } |
2356 | } |
2301 | |
|
|
2302 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
|
|
2303 | |
2357 | |
2304 | int out_of_map (maptile *map, int x, int y) |
2358 | int out_of_map (maptile *map, int x, int y) |
2305 | |
2359 | |
2306 | void |
2360 | void |
2307 | trigger (maptile *map, long connection, bool state = true) |
2361 | trigger (maptile *map, long connection, bool state = true) |
… | |
… | |
2579 | char *buf = SvPVbyte (packet, len); |
2633 | char *buf = SvPVbyte (packet, len); |
2580 | |
2634 | |
2581 | THIS->send_packet (buf, len); |
2635 | THIS->send_packet (buf, len); |
2582 | } |
2636 | } |
2583 | |
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 | |
2584 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2676 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2585 | |
2677 | |
2586 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2678 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2587 | |
2679 | |
2588 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2680 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
… | |
… | |
2611 | set_visibility = 1 |
2703 | set_visibility = 1 |
2612 | set_magicmap = 2 |
2704 | set_magicmap = 2 |
2613 | set_smooth = 3 |
2705 | set_smooth = 3 |
2614 | set_smoothlevel = 4 |
2706 | set_smoothlevel = 4 |
2615 | CODE: |
2707 | CODE: |
2616 | faceinfo *f = face_info (idx); |
2708 | faceinfo *f = face_info (idx); assert (f); |
2617 | assert (f); |
|
|
2618 | switch (ix) |
2709 | switch (ix) |
2619 | { |
2710 | { |
2620 | case 0: f->type = value; break; |
2711 | case 0: f->type = value; break; |
2621 | case 1: f->visibility = value; break; |
2712 | case 1: f->visibility = value; break; |
2622 | case 2: f->magicmap = value; break; |
2713 | case 2: f->magicmap = value; break; |
… | |
… | |
2625 | } |
2716 | } |
2626 | |
2717 | |
2627 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2718 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2628 | CODE: |
2719 | CODE: |
2629 | { |
2720 | { |
2630 | facedata *d = face_data (idx, faceset); |
2721 | faceinfo *f = face_info (idx); assert (f); |
2631 | assert (d); |
2722 | facedata *d = &(faceset ? f->data64 : f->data32); |
2632 | sv_to (data, d->data); |
2723 | sv_to (data, d->data); |
2633 | STRLEN clen; |
2724 | STRLEN clen; |
2634 | char *cdata = SvPVbyte (chksum, clen); |
2725 | char *cdata = SvPVbyte (chksum, clen); |
2635 | clen = min (CHKSUM_SIZE, clen); |
2726 | clen = min (CHKSUM_SIZE, clen); |
2636 | |
2727 | |
… | |
… | |
2646 | ns->force_newmap = true; |
2737 | ns->force_newmap = true; |
2647 | } |
2738 | } |
2648 | } |
2739 | } |
2649 | } |
2740 | } |
2650 | |
2741 | |
|
|
2742 | int get_data_size (faceidx idx, int faceset = 0) |
|
|
2743 | CODE: |
|
|
2744 | facedata *d = face_data (idx, faceset); assert (d); |
|
|
2745 | RETVAL = d->data.size (); |
|
|
2746 | OUTPUT: |
|
|
2747 | RETVAL |
|
|
2748 | |
|
|
2749 | SV *get_chksum (faceidx idx, int faceset = 0) |
|
|
2750 | CODE: |
|
|
2751 | facedata *d = face_data (idx, faceset); assert (d); |
|
|
2752 | RETVAL = newSVpvn ((char *)d->chksum, CHKSUM_SIZE); |
|
|
2753 | OUTPUT: |
|
|
2754 | RETVAL |
|
|
2755 | |
2651 | void invalidate (faceidx idx) |
2756 | void invalidate (faceidx idx) |
2652 | CODE: |
2757 | CODE: |
2653 | for_all_clients (ns) |
2758 | for_all_clients (ns) |
2654 | { |
2759 | { |
2655 | ns->faces_sent [idx] = false; |
2760 | ns->faces_sent [idx] = false; |