… | |
… | |
52 | #include <XSUB.h> |
52 | #include <XSUB.h> |
53 | |
53 | |
54 | #include "CoroAPI.h" |
54 | #include "CoroAPI.h" |
55 | #include "perlxsi.c" |
55 | #include "perlxsi.c" |
56 | |
56 | |
57 | extern sint64 *levels; // the experience table |
|
|
58 | |
|
|
59 | typedef object_thawer &object_thawer_ref; |
57 | typedef object_thawer &object_thawer_ref; |
60 | typedef object_freezer &object_freezer_ref; |
58 | typedef object_freezer &object_freezer_ref; |
61 | |
59 | |
62 | typedef std::string std__string; |
60 | typedef std::string std__string; |
63 | |
61 | |
… | |
… | |
85 | *stash_cf_mapspace_wrap, |
83 | *stash_cf_mapspace_wrap, |
86 | *stash_cf_client_wrap, |
84 | *stash_cf_client_wrap, |
87 | *stash_cf_arch_wrap, |
85 | *stash_cf_arch_wrap, |
88 | *stash_cf_party_wrap, |
86 | *stash_cf_party_wrap, |
89 | *stash_cf_region_wrap, |
87 | *stash_cf_region_wrap, |
90 | *stash_cf_living_wrap; |
88 | *stash_cf_living_wrap, |
|
|
89 | *stash_ext_map_world; |
91 | |
90 | |
92 | static SV |
91 | static SV |
93 | *cv_cf_do_invoke, |
92 | *cv_cf_do_invoke, |
94 | *cv_cf__can_merge, |
93 | *cv_cf__can_merge, |
95 | *cv_cf_client_send_msg, |
94 | *cv_cf_client_send_msg, |
… | |
… | |
230 | do_destroy (); |
229 | do_destroy (); |
231 | sever_self (); |
230 | sever_self (); |
232 | } |
231 | } |
233 | |
232 | |
234 | void |
233 | void |
|
|
234 | attachable::do_delete () |
|
|
235 | { |
|
|
236 | delete this; |
|
|
237 | } |
|
|
238 | |
|
|
239 | void |
235 | attachable::check_mortals () |
240 | attachable::check_mortals () |
236 | { |
241 | { |
237 | static int i = 0; |
242 | static int i = 0; |
238 | |
243 | |
239 | for (;;) |
244 | for (;;) |
… | |
… | |
252 | |
257 | |
253 | if (0) |
258 | if (0) |
254 | { |
259 | { |
255 | for (int j = 0; j < mortals.size (); ++j)//D |
260 | for (int j = 0; j < mortals.size (); ++j)//D |
256 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
261 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
|
|
262 | |
257 | fprintf (stderr, "\n");//D |
263 | fprintf (stderr, "\n");//D |
258 | } |
264 | } |
259 | } |
265 | } |
260 | } |
266 | } |
261 | |
267 | |
… | |
… | |
281 | } |
287 | } |
282 | else |
288 | else |
283 | { |
289 | { |
284 | mortals.erase (i); |
290 | mortals.erase (i); |
285 | obj->sever_self (); |
291 | obj->sever_self (); |
286 | delete obj; |
292 | obj->do_delete (); |
287 | } |
293 | } |
288 | } |
294 | } |
289 | } |
295 | } |
290 | |
296 | |
291 | void |
297 | void |
… | |
… | |
346 | #endif |
352 | #endif |
347 | |
353 | |
348 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
349 | |
355 | |
350 | static SV * |
356 | static SV * |
351 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
357 | newSVptr (void *ptr, HV *stash, HV *hv) |
352 | { |
358 | { |
353 | SV *sv; |
359 | SV *sv; |
354 | |
360 | |
355 | if (!ptr) |
361 | if (!ptr) |
356 | return newSV (0); |
362 | return newSV (0); |
357 | |
363 | |
358 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
364 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
359 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
365 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
|
|
366 | } |
|
|
367 | |
|
|
368 | static SV * |
|
|
369 | newSVptr (void *ptr, HV *stash) |
|
|
370 | { |
|
|
371 | return newSVptr (ptr, stash, newHV ()); |
360 | } |
372 | } |
361 | |
373 | |
362 | static int |
374 | static int |
363 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
375 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
364 | { |
376 | { |
… | |
… | |
472 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
484 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
473 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
485 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
474 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
486 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
475 | && !sv_derived_from (sv, "cf::object"))) |
487 | && !sv_derived_from (sv, "cf::object"))) |
476 | croak ("object of type cf::object expected"); |
488 | croak ("object of type cf::object expected"); |
|
|
489 | |
|
|
490 | return SvPTR_nc (sv); |
|
|
491 | } |
|
|
492 | |
|
|
493 | static long noinline |
|
|
494 | SvPTR_ornull_maptile (SV *sv) |
|
|
495 | { |
|
|
496 | if (expect_false (!SvOK (sv))) return 0; |
|
|
497 | |
|
|
498 | if (!SvROK (sv) |
|
|
499 | || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap |
|
|
500 | && SvSTASH (SvRV (sv)) != stash_ext_map_world |
|
|
501 | && !sv_derived_from (sv, "cf::map"))) |
|
|
502 | croak ("object of type cf::map expected"); |
477 | |
503 | |
478 | return SvPTR_nc (sv); |
504 | return SvPTR_nc (sv); |
479 | } |
505 | } |
480 | |
506 | |
481 | static long noinline |
507 | static long noinline |
… | |
… | |
558 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
584 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
559 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
585 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
560 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
586 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
561 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
587 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
562 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
588 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
563 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
589 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
564 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
590 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
565 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
591 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
|
|
592 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull_maptile (sv); } |
566 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
593 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
567 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
568 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
594 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
569 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
595 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
570 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
596 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
571 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
597 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
572 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
598 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
… | |
… | |
688 | template<class type> |
714 | template<class type> |
689 | static void noinline |
715 | static void noinline |
690 | cf_obj_to (SV *arg, type &var) |
716 | cf_obj_to (SV *arg, type &var) |
691 | { |
717 | { |
692 | sv_to (arg, var); |
718 | sv_to (arg, var); |
693 | if (!var) |
719 | if (expect_false (!var)) |
694 | croak ("must not pass invalid/null cf_obj here"); |
720 | croak ("must not pass invalid/null cf_obj here"); |
695 | } |
721 | } |
696 | |
722 | |
697 | template<class object> |
723 | template<class object> |
698 | static void noinline |
724 | static void noinline |
699 | cf_obj_ornull_to (SV *arg, object *&var) |
725 | cf_obj_ornull_to (SV *arg, object *&var) |
700 | { |
726 | { |
701 | if (SvOK (arg)) |
727 | if (SvOK (arg)) |
702 | { |
728 | { |
703 | sv_to (arg, var); |
729 | sv_to (arg, var); |
704 | if (!var) |
730 | if (expect_false (!var)) |
705 | croak ("unable to convert perl object to C++ object"); |
731 | croak ("unable to convert perl object to C++ object"); |
706 | } |
732 | } |
707 | else |
733 | else |
708 | var = 0; |
734 | var = 0; |
709 | } |
735 | } |
… | |
… | |
744 | exit (EXIT_FAILURE); |
770 | exit (EXIT_FAILURE); |
745 | } |
771 | } |
746 | |
772 | |
747 | eval_pv ( |
773 | eval_pv ( |
748 | "#line 1 'cfperl init'\n" |
774 | "#line 1 'cfperl init'\n" |
749 | "use EV ();\n" |
775 | "use EV ();\n" // required by bootstrap |
750 | "use Coro ();\n" |
776 | "use Coro ();\n" // required by bootstrap |
751 | "cf->bootstrap;\n" |
777 | "cf->bootstrap;\n" // required for cf::datadir |
752 | "unshift @INC, cf::datadir ();\n" |
778 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
753 | "require cf;\n", |
779 | "require cf;\n", |
754 | 0 |
780 | 0 |
755 | ); |
781 | ); |
756 | |
782 | |
757 | if (SvTRUE (ERRSV)) |
783 | if (SvTRUE (ERRSV)) |
… | |
… | |
1132 | |
1158 | |
1133 | return retval; |
1159 | return retval; |
1134 | } |
1160 | } |
1135 | |
1161 | |
1136 | maptile * |
1162 | maptile * |
1137 | find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty) |
1163 | find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty, bool recurse) |
1138 | { |
1164 | { |
1139 | CALL_BEGIN (3); |
1165 | CALL_BEGIN (4); |
1140 | CALL_ARG (dirname); |
1166 | CALL_ARG (dirname); |
1141 | CALL_ARG (stylename); |
1167 | CALL_ARG (stylename); |
1142 | CALL_ARG (difficulty); |
1168 | CALL_ARG (difficulty); |
|
|
1169 | CALL_ARG (recurse); |
1143 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
1170 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
1144 | |
1171 | |
1145 | maptile *retval = 0; |
1172 | maptile *retval = 0; |
1146 | if (count) sv_to (POPs, retval); |
1173 | if (count) sv_to (POPs, retval); |
1147 | |
1174 | |
… | |
… | |
1224 | object::ref () const |
1251 | object::ref () const |
1225 | { |
1252 | { |
1226 | if (type == PLAYER) |
1253 | if (type == PLAYER) |
1227 | return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name); |
1254 | return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name); |
1228 | else |
1255 | else |
|
|
1256 | // TODO: should be able to save references within the same map, at least |
1229 | return 0; |
1257 | return 0; |
1230 | } |
1258 | } |
1231 | |
1259 | |
1232 | object * |
1260 | object * |
1233 | object::deref (const_utf8_string ref) |
1261 | object::deref (const_utf8_string ref) |
… | |
… | |
1369 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1397 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1370 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1398 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1371 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1399 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1372 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1400 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1373 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1401 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1402 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1374 | |
1403 | |
1375 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1404 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1376 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1405 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1377 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1406 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1378 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1407 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
… | |
… | |
1427 | # undef def |
1456 | # undef def |
1428 | # define def(uc, flags) const_iv (SK_ ## uc) |
1457 | # define def(uc, flags) const_iv (SK_ ## uc) |
1429 | # include "skillinc.h" |
1458 | # include "skillinc.h" |
1430 | # undef def |
1459 | # undef def |
1431 | |
1460 | |
1432 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
|
|
1433 | const_iv (logBacktrace) |
|
|
1434 | |
|
|
1435 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1461 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1436 | |
1462 | |
1437 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1463 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1438 | |
1464 | |
1439 | const_iv (MAX_TIME) |
1465 | const_iv (MAX_TIME) |
… | |
… | |
1460 | const_iv (MAP_INACTIVE) |
1486 | const_iv (MAP_INACTIVE) |
1461 | |
1487 | |
1462 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1488 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1463 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1489 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1464 | |
1490 | |
1465 | const_iv (VERSION_CS) const_iv (VERSION_SC) |
|
|
1466 | |
|
|
1467 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1491 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1468 | |
1492 | |
1469 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1493 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1470 | }; |
1494 | }; |
1471 | |
1495 | |
1472 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1496 | for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) |
1473 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1497 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1474 | |
1498 | |
1475 | static const struct { |
1499 | static const struct { |
1476 | const char *name; |
1500 | const char *name; |
1477 | int skip; |
1501 | int skip; |
… | |
… | |
1483 | # undef def |
1507 | # undef def |
1484 | }; |
1508 | }; |
1485 | |
1509 | |
1486 | AV *av = get_av ("cf::EVENT", 1); |
1510 | AV *av = get_av ("cf::EVENT", 1); |
1487 | |
1511 | |
1488 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1512 | for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) |
1489 | { |
1513 | { |
1490 | AV *event = newAV (); |
1514 | AV *event = newAV (); |
1491 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1515 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1492 | av_push (event, newSViv (eiv->klass)); |
1516 | av_push (event, newSViv (eiv->klass)); |
1493 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1517 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1658 | switch (items) |
1682 | switch (items) |
1659 | { |
1683 | { |
1660 | case 0: RETVAL = gen (); break; |
1684 | case 0: RETVAL = gen (); break; |
1661 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1685 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1662 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1686 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1663 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1687 | default: croak ("cf::rndm requires zero, one or two parameters."); break; |
1664 | } |
1688 | } |
1665 | } |
1689 | } |
1666 | OUTPUT: |
1690 | OUTPUT: |
1667 | RETVAL |
1691 | RETVAL |
1668 | |
1692 | |
… | |
… | |
1684 | PROTOTYPE: @ |
1708 | PROTOTYPE: @ |
1685 | CODE: |
1709 | CODE: |
1686 | while (items > 0) |
1710 | while (items > 0) |
1687 | sv_rvweaken (ST (--items)); |
1711 | sv_rvweaken (ST (--items)); |
1688 | |
1712 | |
1689 | void |
1713 | void log_suspend () |
|
|
1714 | |
|
|
1715 | void log_resume () |
|
|
1716 | |
1690 | log_backtrace (utf8_string msg) |
1717 | void log_backtrace (utf8_string msg) |
1691 | |
1718 | |
1692 | void |
|
|
1693 | LOG (int flags, utf8_string msg) |
1719 | void LOG (int flags, utf8_string msg) |
1694 | PROTOTYPE: $$ |
1720 | PROTOTYPE: $$ |
1695 | C_ARGS: flags, "%s", msg |
1721 | C_ARGS: flags, "%s", msg |
1696 | |
1722 | |
1697 | octet_string path_combine (octet_string base, octet_string path) |
1723 | octet_string path_combine (octet_string base, octet_string path) |
1698 | PROTOTYPE: $$ |
1724 | PROTOTYPE: $$ |
… | |
… | |
1790 | |
1816 | |
1791 | int random_roll (int min, int max, object *op, int goodbad); |
1817 | int random_roll (int min, int max, object *op, int goodbad); |
1792 | |
1818 | |
1793 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1819 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1794 | |
1820 | |
1795 | int |
|
|
1796 | exp_to_level (val64 exp) |
1821 | int exp_to_level (val64 exp) |
1797 | CODE: |
|
|
1798 | { |
|
|
1799 | int i = 0; |
|
|
1800 | |
1822 | |
1801 | RETVAL = settings.max_level; |
|
|
1802 | |
|
|
1803 | for (i = 1; i <= settings.max_level; i++) |
|
|
1804 | { |
|
|
1805 | if (levels[i] > exp) |
|
|
1806 | { |
|
|
1807 | RETVAL = i - 1; |
|
|
1808 | break; |
|
|
1809 | } |
|
|
1810 | } |
|
|
1811 | } |
|
|
1812 | OUTPUT: RETVAL |
|
|
1813 | |
|
|
1814 | val64 |
|
|
1815 | level_to_min_exp (int level) |
1823 | val64 level_to_min_exp (int level) |
1816 | CODE: |
|
|
1817 | if (level > settings.max_level) |
|
|
1818 | RETVAL = levels[settings.max_level]; |
|
|
1819 | else if (level < 1) |
|
|
1820 | RETVAL = 0; |
|
|
1821 | else |
|
|
1822 | RETVAL = levels[level]; |
|
|
1823 | OUTPUT: RETVAL |
|
|
1824 | |
1824 | |
1825 | SV * |
1825 | SV * |
1826 | resistance_to_string (int atnr) |
1826 | resistance_to_string (int atnr) |
1827 | CODE: |
1827 | CODE: |
1828 | if (atnr >= 0 && atnr < NROFATTACKS) |
1828 | if (atnr >= 0 && atnr < NROFATTACKS) |
… | |
… | |
1886 | CODE: |
1886 | CODE: |
1887 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1887 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1888 | OUTPUT: |
1888 | OUTPUT: |
1889 | RETVAL |
1889 | RETVAL |
1890 | |
1890 | |
|
|
1891 | bool should_invoke (attachable *obj, int event) |
|
|
1892 | CODE: |
|
|
1893 | RETVAL = obj->should_invoke ((event_type)event); |
|
|
1894 | OUTPUT: RETVAL |
|
|
1895 | |
1891 | void |
1896 | void |
1892 | debug_trace (attachable *obj, bool on = true) |
1897 | debug_trace (attachable *obj, bool on = true) |
1893 | CODE: |
1898 | CODE: |
1894 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1899 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1895 | if (on) |
1900 | if (on) |
… | |
… | |
2020 | OUTPUT: |
2025 | OUTPUT: |
2021 | RETVAL |
2026 | RETVAL |
2022 | |
2027 | |
2023 | object *find_best_object_match (object *op, utf8_string match) |
2028 | object *find_best_object_match (object *op, utf8_string match) |
2024 | |
2029 | |
2025 | object *find_marked_object (object *op) |
|
|
2026 | |
|
|
2027 | int need_identify (object *obj); |
|
|
2028 | |
|
|
2029 | int apply_shop_mat (object *shop_mat, object *op); |
2030 | int apply_shop_mat (object *shop_mat, object *op); |
2030 | |
2031 | |
2031 | int move (object *op, int dir, object *originator = op) |
2032 | int move (object *op, int dir, object *originator = op) |
2032 | CODE: |
2033 | CODE: |
2033 | RETVAL = op->move (dir, originator); |
2034 | RETVAL = op->move (dir, originator); |
… | |
… | |
2085 | |
2086 | |
2086 | void pick_up (object *who, object *op) |
2087 | void pick_up (object *who, object *op) |
2087 | |
2088 | |
2088 | void update_object (object *op, int action) |
2089 | void update_object (object *op, int action) |
2089 | |
2090 | |
2090 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
2091 | void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0) |
2091 | |
2092 | |
2092 | void player_lvl_adj (object *who, object *skill = 0) |
2093 | void player_lvl_adj (object *who, object *skill = 0) |
2093 | |
2094 | |
2094 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2095 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2095 | |
2096 | |
… | |
… | |
2158 | PROTOTYPE: $$;$ |
2159 | PROTOTYPE: $$;$ |
2159 | PPCODE: |
2160 | PPCODE: |
2160 | { |
2161 | { |
2161 | rv_vector rv; |
2162 | rv_vector rv; |
2162 | |
2163 | |
2163 | PUTBACK; |
|
|
2164 | get_rangevector (ob, other, &rv, flags); |
2164 | get_rangevector (ob, other, &rv, flags); |
2165 | SPAGAIN; |
|
|
2166 | |
2165 | |
2167 | EXTEND (SP, 5); |
2166 | EXTEND (SP, 5); |
2168 | PUSHs (newSVuv (rv.distance)); |
2167 | PUSHs (sv_2mortal (newSVuv (rv.distance))); |
2169 | PUSHs (newSViv (rv.distance_x)); |
2168 | PUSHs (sv_2mortal (newSViv (rv.distance_x))); |
2170 | PUSHs (newSViv (rv.distance_y)); |
2169 | PUSHs (sv_2mortal (newSViv (rv.distance_y))); |
2171 | PUSHs (newSViv (rv.direction)); |
2170 | PUSHs (sv_2mortal (newSViv (rv.direction))); |
2172 | PUSHs (to_sv (rv.part)); |
2171 | PUSHs (sv_2mortal (to_sv (rv.part))); |
2173 | } |
2172 | } |
2174 | |
2173 | |
2175 | bool on_same_map_as (object *ob, object *other) |
2174 | bool on_same_map_as (object *ob, object *other) |
2176 | CODE: |
2175 | CODE: |
2177 | RETVAL = on_same_map (ob, other); |
2176 | RETVAL = on_same_map (ob, other); |
… | |
… | |
2462 | if (oblinkpt *obp = map->find_link (connection)) |
2461 | if (oblinkpt *obp = map->find_link (connection)) |
2463 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2462 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2464 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2463 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2465 | |
2464 | |
2466 | void |
2465 | void |
2467 | get_map_flags (maptile *map, int x, int y) |
2466 | xy_normalise (maptile *map, int x, int y, int dir = 0) |
2468 | PPCODE: |
2467 | PPCODE: |
2469 | { |
2468 | { |
2470 | maptile *nmap = 0; |
2469 | mapxy pos (map, x, y); |
2471 | I16 nx = 0, ny = 0; |
2470 | if (!pos.move (dir).normalise ()) |
|
|
2471 | XSRETURN_EMPTY; |
2472 | |
2472 | |
2473 | PUTBACK; |
|
|
2474 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2475 | SPAGAIN; |
|
|
2476 | |
|
|
2477 | EXTEND (SP, 4); |
2473 | EXTEND (SP, 3); |
2478 | PUSHs (sv_2mortal (newSViv (flags))); |
|
|
2479 | |
|
|
2480 | if (GIMME_V == G_ARRAY) |
|
|
2481 | { |
|
|
2482 | PUSHs (sv_2mortal (to_sv (nmap))); |
2474 | PUSHs (sv_2mortal (to_sv (pos.m))); |
2483 | PUSHs (sv_2mortal (newSViv (nx))); |
2475 | PUSHs (sv_2mortal (to_sv (pos.x))); |
2484 | PUSHs (sv_2mortal (newSViv (ny))); |
2476 | PUSHs (sv_2mortal (to_sv (pos.y))); |
2485 | } |
|
|
2486 | } |
2477 | } |
2487 | |
2478 | |
2488 | mapspace * |
2479 | mapspace * |
2489 | ms (maptile *map, unsigned int x, unsigned int y) |
2480 | ms (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2490 | PROTOTYPE: $$$ |
2481 | PROTOTYPE: $$$;$ |
2491 | CODE: |
2482 | CODE: |
2492 | { |
2483 | { |
2493 | maptile *nmap = 0; |
2484 | mapxy pos (map, x, y); |
2494 | I16 nx, ny; |
2485 | if (!pos.move (dir).normalise ()) |
2495 | |
|
|
2496 | PUTBACK; |
|
|
2497 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2498 | SPAGAIN; |
|
|
2499 | |
|
|
2500 | if (!nmap) |
|
|
2501 | XSRETURN_UNDEF; |
2486 | XSRETURN_UNDEF; |
2502 | |
2487 | |
2503 | RETVAL = &nmap->at (nx, ny); |
2488 | RETVAL = &*pos; |
2504 | } |
2489 | } |
2505 | OUTPUT: |
2490 | OUTPUT: |
2506 | RETVAL |
2491 | RETVAL |
2507 | |
2492 | |
2508 | void |
2493 | void |
2509 | at (maptile *map, unsigned int x, unsigned int y) |
2494 | at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2510 | PROTOTYPE: $$$ |
2495 | PROTOTYPE: $$$;$ |
2511 | PPCODE: |
2496 | PPCODE: |
2512 | { |
2497 | mapxy pos (map, x, y); |
2513 | maptile *nmap = 0; |
2498 | if (pos.move (dir).normalise ()) |
2514 | I16 nx, ny; |
|
|
2515 | |
|
|
2516 | PUTBACK; |
|
|
2517 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2518 | SPAGAIN; |
|
|
2519 | |
|
|
2520 | if (nmap) |
|
|
2521 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2499 | for (object *o = pos->bot; o; o = o->above) |
2522 | XPUSHs (sv_2mortal (to_sv (o))); |
2500 | XPUSHs (sv_2mortal (to_sv (o))); |
2523 | } |
|
|
2524 | |
2501 | |
2525 | SV * |
2502 | SV * |
2526 | bot_at (maptile *map, unsigned int x, unsigned int y) |
2503 | bot_at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2527 | PROTOTYPE: $$$ |
2504 | PROTOTYPE: $$$;$ |
2528 | ALIAS: |
2505 | ALIAS: |
2529 | top_at = 1 |
2506 | top_at = 1 |
2530 | flags_at = 2 |
2507 | flags_at = 2 |
2531 | light_at = 3 |
2508 | light_at = 3 |
2532 | move_block_at = 4 |
2509 | move_block_at = 4 |
2533 | move_slow_at = 5 |
2510 | move_slow_at = 5 |
2534 | move_on_at = 6 |
2511 | move_on_at = 6 |
2535 | move_off_at = 7 |
2512 | move_off_at = 7 |
2536 | CODE: |
2513 | CODE: |
2537 | { |
2514 | { |
2538 | sint16 nx = x; |
2515 | mapxy pos (map, x, y); |
2539 | sint16 ny = y; |
2516 | if (!pos.move (dir).normalise ()) |
2540 | |
|
|
2541 | if (!xy_normalise (map, nx, ny)) |
|
|
2542 | XSRETURN_UNDEF; |
2517 | XSRETURN_UNDEF; |
2543 | |
2518 | |
2544 | mapspace &ms = map->at (nx, ny); |
2519 | mapspace &ms = *pos; |
2545 | |
2520 | |
2546 | ms.update (); |
2521 | ms.update (); |
2547 | |
2522 | |
2548 | switch (ix) |
2523 | switch (ix) |
2549 | { |
2524 | { |
… | |
… | |
2683 | list () |
2658 | list () |
2684 | PPCODE: |
2659 | PPCODE: |
2685 | for_all_regions (rgn) |
2660 | for_all_regions (rgn) |
2686 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2661 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2687 | |
2662 | |
2688 | region *find (utf8_string name) |
|
|
2689 | PROTOTYPE: $ |
|
|
2690 | CODE: |
|
|
2691 | RETVAL = region::find (name); |
|
|
2692 | OUTPUT: RETVAL |
|
|
2693 | |
|
|
2694 | int specificity (region *rgn) |
2663 | int specificity (region *rgn) |
2695 | CODE: |
2664 | CODE: |
2696 | RETVAL = 0; |
2665 | RETVAL = 0; |
2697 | while (rgn = rgn->parent) |
2666 | while (rgn = rgn->parent) |
2698 | RETVAL++; |
2667 | RETVAL++; |
… | |
… | |
2801 | while (!RETVAL); // crude way to leave index 0 |
2770 | while (!RETVAL); // crude way to leave index 0 |
2802 | |
2771 | |
2803 | faces [RETVAL].name = name; |
2772 | faces [RETVAL].name = name; |
2804 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2773 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2805 | |
2774 | |
2806 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2775 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2807 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2776 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
|
|
2777 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2808 | } |
2778 | } |
2809 | OUTPUT: RETVAL |
2779 | OUTPUT: RETVAL |
2810 | |
2780 | |
2811 | void set_type (faceidx idx, int value) |
2781 | void set_type (faceidx idx, int value) |
2812 | ALIAS: |
2782 | ALIAS: |
… | |
… | |
2946 | sv_to (sv, self); |
2916 | sv_to (sv, self); |
2947 | delete self; |
2917 | delete self; |
2948 | |
2918 | |
2949 | MODULE = cf PACKAGE = cf::object::thawer |
2919 | MODULE = cf PACKAGE = cf::object::thawer |
2950 | |
2920 | |
2951 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/cfperl.h | |
2921 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h | |
|
|
2922 | |
|
|
2923 | bool |
|
|
2924 | errors_are_fatal (bool fatal) |
|
|
2925 | CODE: |
|
|
2926 | RETVAL = object_thawer::errors_are_fatal; |
|
|
2927 | object_thawer::errors_are_fatal = fatal; |
|
|
2928 | OUTPUT: |
|
|
2929 | RETVAL |
2952 | |
2930 | |
2953 | SV * |
2931 | SV * |
2954 | new_from_file (char *klass, octet_string path) |
2932 | new_from_file (char *klass, octet_string path) |
2955 | CODE: |
2933 | CODE: |
2956 | object_thawer *f = new object_thawer (path); |
2934 | object_thawer *f = new object_thawer (path); |