… | |
… | |
83 | *stash_cf_mapspace_wrap, |
83 | *stash_cf_mapspace_wrap, |
84 | *stash_cf_client_wrap, |
84 | *stash_cf_client_wrap, |
85 | *stash_cf_arch_wrap, |
85 | *stash_cf_arch_wrap, |
86 | *stash_cf_party_wrap, |
86 | *stash_cf_party_wrap, |
87 | *stash_cf_region_wrap, |
87 | *stash_cf_region_wrap, |
88 | *stash_cf_living_wrap; |
88 | *stash_cf_living_wrap, |
|
|
89 | *stash_cf_layout_wrap, |
|
|
90 | *stash_ext_map_world; |
89 | |
91 | |
90 | static SV |
92 | static SV |
91 | *cv_cf_do_invoke, |
93 | *cv_cf_do_invoke, |
92 | *cv_cf__can_merge, |
94 | *cv_cf__can_merge, |
93 | *cv_cf_client_send_msg, |
95 | *cv_cf_client_send_msg, |
… | |
… | |
121 | |
123 | |
122 | return sv; |
124 | return sv; |
123 | } |
125 | } |
124 | #endif |
126 | #endif |
125 | |
127 | |
126 | static noinline utf8_string |
128 | noinline utf8_string |
127 | cfSvPVutf8_nolen (SV *sv) |
129 | cfSvPVutf8_nolen (SV *sv) |
128 | { |
130 | { |
129 | SvGETMAGIC (sv); |
131 | SvGETMAGIC (sv); |
130 | |
132 | |
131 | if (SvPOK (sv)) |
133 | if (SvPOK (sv)) |
… | |
… | |
351 | #endif |
353 | #endif |
352 | |
354 | |
353 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
354 | |
356 | |
355 | static SV * |
357 | static SV * |
356 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
358 | newSVptr (void *ptr, HV *stash, HV *hv) |
357 | { |
359 | { |
358 | SV *sv; |
|
|
359 | |
|
|
360 | if (!ptr) |
360 | if (!ptr) |
361 | return newSV (0); |
361 | return newSV (0); |
362 | |
362 | |
363 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
363 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
364 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
364 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
|
|
365 | } |
|
|
366 | |
|
|
367 | static SV * noinline |
|
|
368 | newSVptr (void *ptr, HV *stash) |
|
|
369 | { |
|
|
370 | return newSVptr (ptr, stash, newHV ()); |
365 | } |
371 | } |
366 | |
372 | |
367 | static int |
373 | static int |
368 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
374 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
369 | { |
375 | { |
… | |
… | |
381 | return 0; |
387 | return 0; |
382 | } |
388 | } |
383 | |
389 | |
384 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
390 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
385 | |
391 | |
386 | static SV * |
392 | static SV * noinline |
387 | newSVattachable (attachable *obj, HV *stash) |
393 | newSVattachable (attachable *obj, HV *stash) |
388 | { |
394 | { |
389 | if (!obj) |
395 | if (!obj) |
390 | return newSV (0); |
396 | return newSV (0); |
391 | |
397 | |
… | |
… | |
477 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
483 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
478 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
484 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
479 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
485 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
480 | && !sv_derived_from (sv, "cf::object"))) |
486 | && !sv_derived_from (sv, "cf::object"))) |
481 | croak ("object of type cf::object expected"); |
487 | croak ("object of type cf::object expected"); |
|
|
488 | |
|
|
489 | return SvPTR_nc (sv); |
|
|
490 | } |
|
|
491 | |
|
|
492 | static long noinline |
|
|
493 | SvPTR_ornull_maptile (SV *sv) |
|
|
494 | { |
|
|
495 | if (expect_false (!SvOK (sv))) return 0; |
|
|
496 | |
|
|
497 | if (!SvROK (sv) |
|
|
498 | || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap |
|
|
499 | && SvSTASH (SvRV (sv)) != stash_ext_map_world |
|
|
500 | && !sv_derived_from (sv, "cf::map"))) |
|
|
501 | croak ("object of type cf::map expected"); |
482 | |
502 | |
483 | return SvPTR_nc (sv); |
503 | return SvPTR_nc (sv); |
484 | } |
504 | } |
485 | |
505 | |
486 | static long noinline |
506 | static long noinline |
… | |
… | |
511 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
531 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
512 | static inline SV *to_sv (float v) { return newSVnv (v); } |
532 | static inline SV *to_sv (float v) { return newSVnv (v); } |
513 | static inline SV *to_sv (double v) { return newSVnv (v); } |
533 | static inline SV *to_sv (double v) { return newSVnv (v); } |
514 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
534 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
515 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
535 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
|
|
536 | // gcc dislikes noilnine on to_sv |
516 | static inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
537 | static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
|
|
538 | static inline SV *to_sv (object * v) { return to_sv_ni (v); } |
517 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
539 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
518 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
540 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
519 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
541 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
520 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
542 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
521 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
543 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
522 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
544 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
|
|
545 | static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); } |
523 | |
546 | |
524 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
547 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
525 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
548 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
526 | |
549 | |
527 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
550 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
… | |
… | |
563 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
586 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
564 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
587 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
565 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
588 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
566 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
589 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
567 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
590 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
568 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
591 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
569 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
592 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
570 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
593 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
|
|
594 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull_maptile (sv); } |
571 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
595 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
572 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
573 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
596 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
574 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
597 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
575 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
598 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
576 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
599 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
577 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
600 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
|
|
601 | static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); } |
578 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
602 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
579 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
603 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
580 | |
604 | |
581 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
605 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
582 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
606 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
693 | template<class type> |
717 | template<class type> |
694 | static void noinline |
718 | static void noinline |
695 | cf_obj_to (SV *arg, type &var) |
719 | cf_obj_to (SV *arg, type &var) |
696 | { |
720 | { |
697 | sv_to (arg, var); |
721 | sv_to (arg, var); |
698 | if (!var) |
722 | if (expect_false (!var)) |
699 | croak ("must not pass invalid/null cf_obj here"); |
723 | croak ("must not pass invalid/null cf_obj here"); |
700 | } |
724 | } |
701 | |
725 | |
702 | template<class object> |
726 | template<class object> |
703 | static void noinline |
727 | static void noinline |
704 | cf_obj_ornull_to (SV *arg, object *&var) |
728 | cf_obj_ornull_to (SV *arg, object *&var) |
705 | { |
729 | { |
706 | if (SvOK (arg)) |
730 | if (SvOK (arg)) |
707 | { |
731 | { |
708 | sv_to (arg, var); |
732 | sv_to (arg, var); |
709 | if (!var) |
733 | if (expect_false (!var)) |
710 | croak ("unable to convert perl object to C++ object"); |
734 | croak ("unable to convert perl object to C++ object"); |
711 | } |
735 | } |
712 | else |
736 | else |
713 | var = 0; |
737 | var = 0; |
714 | } |
738 | } |
… | |
… | |
749 | exit (EXIT_FAILURE); |
773 | exit (EXIT_FAILURE); |
750 | } |
774 | } |
751 | |
775 | |
752 | eval_pv ( |
776 | eval_pv ( |
753 | "#line 1 'cfperl init'\n" |
777 | "#line 1 'cfperl init'\n" |
754 | "use EV ();\n" |
778 | "use EV ();\n" // required by bootstrap |
755 | "use Coro ();\n" |
779 | "use Coro ();\n" // required by bootstrap |
756 | "cf->bootstrap;\n" |
780 | "cf->bootstrap;\n" // required for cf::datadir |
757 | "unshift @INC, cf::datadir ();\n" |
781 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
758 | "require cf;\n", |
782 | "require cf;\n", |
759 | 0 |
783 | 0 |
760 | ); |
784 | ); |
761 | |
785 | |
762 | if (SvTRUE (ERRSV)) |
786 | if (SvTRUE (ERRSV)) |
… | |
… | |
1376 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1400 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1377 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1401 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1378 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1402 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1379 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1403 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1380 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1404 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1405 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
|
|
1406 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1381 | |
1407 | |
1382 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1408 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1383 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1409 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1384 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1410 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1385 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1411 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
… | |
… | |
1434 | # undef def |
1460 | # undef def |
1435 | # define def(uc, flags) const_iv (SK_ ## uc) |
1461 | # define def(uc, flags) const_iv (SK_ ## uc) |
1436 | # include "skillinc.h" |
1462 | # include "skillinc.h" |
1437 | # undef def |
1463 | # undef def |
1438 | |
1464 | |
1439 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
|
|
1440 | const_iv (logBacktrace) |
|
|
1441 | |
|
|
1442 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1465 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1443 | |
1466 | |
1444 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1467 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1445 | |
1468 | |
1446 | const_iv (MAX_TIME) |
1469 | const_iv (MAX_TIME) |
… | |
… | |
1472 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1495 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1473 | |
1496 | |
1474 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1497 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1475 | }; |
1498 | }; |
1476 | |
1499 | |
1477 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1500 | for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) |
1478 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1501 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1479 | |
1502 | |
1480 | static const struct { |
1503 | static const struct { |
1481 | const char *name; |
1504 | const char *name; |
1482 | int skip; |
1505 | int skip; |
… | |
… | |
1488 | # undef def |
1511 | # undef def |
1489 | }; |
1512 | }; |
1490 | |
1513 | |
1491 | AV *av = get_av ("cf::EVENT", 1); |
1514 | AV *av = get_av ("cf::EVENT", 1); |
1492 | |
1515 | |
1493 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1516 | for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) |
1494 | { |
1517 | { |
1495 | AV *event = newAV (); |
1518 | AV *event = newAV (); |
1496 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1519 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1497 | av_push (event, newSViv (eiv->klass)); |
1520 | av_push (event, newSViv (eiv->klass)); |
1498 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1521 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1579 | |
1602 | |
1580 | void init_anim () |
1603 | void init_anim () |
1581 | |
1604 | |
1582 | void init_globals () |
1605 | void init_globals () |
1583 | |
1606 | |
1584 | void init_experience () |
|
|
1585 | |
|
|
1586 | void init_attackmess () |
1607 | void init_attackmess () |
1587 | |
1608 | |
1588 | void init_dynamic () |
1609 | void init_dynamic () |
1589 | |
1610 | |
1590 | void load_settings () |
1611 | void load_settings () |
1591 | |
1612 | |
|
|
1613 | void reload_exp_table () |
|
|
1614 | |
1592 | void load_materials () |
1615 | void reload_materials () |
1593 | |
1616 | |
1594 | void init_uuid () |
1617 | void init_uuid () |
1595 | CODE: |
1618 | CODE: |
1596 | UUID::init (); |
1619 | UUID::init (); |
1597 | |
1620 | |
… | |
… | |
1867 | CODE: |
1890 | CODE: |
1868 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1891 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1869 | OUTPUT: |
1892 | OUTPUT: |
1870 | RETVAL |
1893 | RETVAL |
1871 | |
1894 | |
|
|
1895 | bool should_invoke (attachable *obj, int event) |
|
|
1896 | CODE: |
|
|
1897 | RETVAL = obj->should_invoke ((event_type)event); |
|
|
1898 | OUTPUT: RETVAL |
|
|
1899 | |
1872 | void |
1900 | void |
1873 | debug_trace (attachable *obj, bool on = true) |
1901 | debug_trace (attachable *obj, bool on = true) |
1874 | CODE: |
1902 | CODE: |
1875 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1903 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1876 | if (on) |
1904 | if (on) |
… | |
… | |
2062 | |
2090 | |
2063 | void pick_up (object *who, object *op) |
2091 | void pick_up (object *who, object *op) |
2064 | |
2092 | |
2065 | void update_object (object *op, int action) |
2093 | void update_object (object *op, int action) |
2066 | |
2094 | |
2067 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
2095 | void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0) |
2068 | |
2096 | |
2069 | void player_lvl_adj (object *who, object *skill = 0) |
2097 | void player_lvl_adj (object *who, object *skill = 0) |
2070 | |
2098 | |
2071 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2099 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2072 | |
2100 | |
… | |
… | |
2437 | if (oblinkpt *obp = map->find_link (connection)) |
2465 | if (oblinkpt *obp = map->find_link (connection)) |
2438 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2466 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2439 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2467 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2440 | |
2468 | |
2441 | void |
2469 | void |
2442 | get_map_flags (maptile *map, int x, int y) |
2470 | xy_normalise (maptile *map, int x, int y, int dir = 0) |
2443 | PPCODE: |
2471 | PPCODE: |
2444 | { |
2472 | { |
2445 | maptile *nmap = 0; |
2473 | mapxy pos (map, x, y); |
2446 | I16 nx = 0, ny = 0; |
2474 | if (!pos.move (dir).normalise ()) |
|
|
2475 | XSRETURN_EMPTY; |
2447 | |
2476 | |
2448 | PUTBACK; |
|
|
2449 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2450 | SPAGAIN; |
|
|
2451 | |
|
|
2452 | EXTEND (SP, 4); |
2477 | EXTEND (SP, 3); |
2453 | PUSHs (sv_2mortal (newSViv (flags))); |
|
|
2454 | |
|
|
2455 | if (GIMME_V == G_ARRAY) |
|
|
2456 | { |
|
|
2457 | PUSHs (sv_2mortal (to_sv (nmap))); |
2478 | PUSHs (sv_2mortal (to_sv (pos.m))); |
2458 | PUSHs (sv_2mortal (newSViv (nx))); |
2479 | PUSHs (sv_2mortal (to_sv (pos.x))); |
2459 | PUSHs (sv_2mortal (newSViv (ny))); |
2480 | PUSHs (sv_2mortal (to_sv (pos.y))); |
2460 | } |
|
|
2461 | } |
2481 | } |
2462 | |
2482 | |
2463 | mapspace * |
2483 | mapspace * |
2464 | ms (maptile *map, unsigned int x, unsigned int y) |
2484 | ms (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2465 | PROTOTYPE: $$$ |
2485 | PROTOTYPE: $$$;$ |
2466 | CODE: |
2486 | CODE: |
2467 | { |
2487 | { |
2468 | maptile *nmap = 0; |
2488 | mapxy pos (map, x, y); |
2469 | I16 nx, ny; |
2489 | if (!pos.move (dir).normalise ()) |
2470 | |
|
|
2471 | PUTBACK; |
|
|
2472 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2473 | SPAGAIN; |
|
|
2474 | |
|
|
2475 | if (!nmap) |
|
|
2476 | XSRETURN_UNDEF; |
2490 | XSRETURN_UNDEF; |
2477 | |
2491 | |
2478 | RETVAL = &nmap->at (nx, ny); |
2492 | RETVAL = &*pos; |
2479 | } |
2493 | } |
2480 | OUTPUT: |
2494 | OUTPUT: |
2481 | RETVAL |
2495 | RETVAL |
2482 | |
2496 | |
2483 | void |
2497 | void |
2484 | at (maptile *map, unsigned int x, unsigned int y) |
2498 | at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2485 | PROTOTYPE: $$$ |
2499 | PROTOTYPE: $$$;$ |
2486 | PPCODE: |
2500 | PPCODE: |
2487 | { |
2501 | mapxy pos (map, x, y); |
2488 | maptile *nmap = 0; |
2502 | if (pos.move (dir).normalise ()) |
2489 | I16 nx, ny; |
|
|
2490 | |
|
|
2491 | PUTBACK; |
|
|
2492 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2493 | SPAGAIN; |
|
|
2494 | |
|
|
2495 | if (nmap) |
|
|
2496 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2503 | for (object *o = pos->bot; o; o = o->above) |
2497 | XPUSHs (sv_2mortal (to_sv (o))); |
2504 | XPUSHs (sv_2mortal (to_sv (o))); |
2498 | } |
|
|
2499 | |
2505 | |
2500 | SV * |
2506 | SV * |
2501 | bot_at (maptile *map, unsigned int x, unsigned int y) |
2507 | bot_at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2502 | PROTOTYPE: $$$ |
2508 | PROTOTYPE: $$$;$ |
2503 | ALIAS: |
2509 | ALIAS: |
2504 | top_at = 1 |
2510 | top_at = 1 |
2505 | flags_at = 2 |
2511 | flags_at = 2 |
2506 | light_at = 3 |
2512 | light_at = 3 |
2507 | move_block_at = 4 |
2513 | move_block_at = 4 |
2508 | move_slow_at = 5 |
2514 | move_slow_at = 5 |
2509 | move_on_at = 6 |
2515 | move_on_at = 6 |
2510 | move_off_at = 7 |
2516 | move_off_at = 7 |
2511 | CODE: |
2517 | CODE: |
2512 | { |
2518 | { |
2513 | sint16 nx = x; |
2519 | mapxy pos (map, x, y); |
2514 | sint16 ny = y; |
2520 | if (!pos.move (dir).normalise ()) |
2515 | |
|
|
2516 | if (!xy_normalise (map, nx, ny)) |
|
|
2517 | XSRETURN_UNDEF; |
2521 | XSRETURN_UNDEF; |
2518 | |
2522 | |
2519 | mapspace &ms = map->at (nx, ny); |
2523 | mapspace &ms = *pos; |
2520 | |
2524 | |
2521 | ms.update (); |
2525 | ms.update (); |
2522 | |
2526 | |
2523 | switch (ix) |
2527 | switch (ix) |
2524 | { |
2528 | { |
… | |
… | |
2534 | } |
2538 | } |
2535 | OUTPUT: RETVAL |
2539 | OUTPUT: RETVAL |
2536 | |
2540 | |
2537 | # worst xs function of my life |
2541 | # worst xs function of my life |
2538 | bool |
2542 | bool |
2539 | _create_random_map (\ |
2543 | _create_random_map (maptile *self, SV *options) |
2540 | maptile *self,\ |
|
|
2541 | utf8_string wallstyle,\ |
|
|
2542 | utf8_string wall_name,\ |
|
|
2543 | utf8_string floorstyle,\ |
|
|
2544 | utf8_string monsterstyle,\ |
|
|
2545 | utf8_string treasurestyle,\ |
|
|
2546 | utf8_string layoutstyle,\ |
|
|
2547 | utf8_string doorstyle,\ |
|
|
2548 | utf8_string decorstyle,\ |
|
|
2549 | utf8_string miningstyle,\ |
|
|
2550 | utf8_string origin_map,\ |
|
|
2551 | utf8_string final_map,\ |
|
|
2552 | utf8_string exitstyle,\ |
|
|
2553 | utf8_string this_map,\ |
|
|
2554 | utf8_string exit_on_final_map,\ |
|
|
2555 | int xsize,\ |
|
|
2556 | int ysize,\ |
|
|
2557 | int expand2x,\ |
|
|
2558 | int layoutoptions1,\ |
|
|
2559 | int layoutoptions2,\ |
|
|
2560 | int layoutoptions3,\ |
|
|
2561 | int symmetry,\ |
|
|
2562 | int difficulty,\ |
|
|
2563 | int difficulty_given,\ |
|
|
2564 | float difficulty_increase,\ |
|
|
2565 | int dungeon_level,\ |
|
|
2566 | int dungeon_depth,\ |
|
|
2567 | int decoroptions,\ |
|
|
2568 | int orientation,\ |
|
|
2569 | int origin_y,\ |
|
|
2570 | int origin_x,\ |
|
|
2571 | U32 random_seed,\ |
|
|
2572 | val64 total_map_hp,\ |
|
|
2573 | int map_layout_style,\ |
|
|
2574 | int treasureoptions,\ |
|
|
2575 | int symmetry_used,\ |
|
|
2576 | region *region,\ |
|
|
2577 | utf8_string custom\ |
|
|
2578 | ) |
|
|
2579 | CODE: |
2544 | CODE: |
2580 | { |
2545 | { |
2581 | random_map_params rmp; |
2546 | random_map_params rmp ((HV *)SvRV (options)); |
2582 | |
|
|
2583 | assign (rmp.wallstyle , wallstyle); |
|
|
2584 | assign (rmp.wall_name , wall_name); |
|
|
2585 | assign (rmp.floorstyle , floorstyle); |
|
|
2586 | assign (rmp.monsterstyle , monsterstyle); |
|
|
2587 | assign (rmp.treasurestyle , treasurestyle); |
|
|
2588 | assign (rmp.layoutstyle , layoutstyle); |
|
|
2589 | assign (rmp.doorstyle , doorstyle); |
|
|
2590 | assign (rmp.decorstyle , decorstyle); |
|
|
2591 | assign (rmp.miningstyle , miningstyle); |
|
|
2592 | assign (rmp.exitstyle , exitstyle); |
|
|
2593 | assign (rmp.exit_on_final_map, exit_on_final_map); |
|
|
2594 | |
|
|
2595 | rmp.origin_map = origin_map; |
|
|
2596 | rmp.final_map = final_map; |
|
|
2597 | rmp.this_map = this_map; |
|
|
2598 | rmp.xsize = xsize; |
|
|
2599 | rmp.ysize = ysize; |
|
|
2600 | rmp.expand2x = expand2x; |
|
|
2601 | rmp.layoutoptions1 = layoutoptions1; |
|
|
2602 | rmp.layoutoptions2 = layoutoptions2; |
|
|
2603 | rmp.layoutoptions3 = layoutoptions3; |
|
|
2604 | rmp.symmetry = symmetry; |
|
|
2605 | rmp.difficulty = difficulty; |
|
|
2606 | rmp.difficulty_given = difficulty_given; |
|
|
2607 | rmp.difficulty_increase = difficulty_increase; |
|
|
2608 | rmp.dungeon_level = dungeon_level; |
|
|
2609 | rmp.dungeon_depth = dungeon_depth; |
|
|
2610 | rmp.decoroptions = decoroptions; |
|
|
2611 | rmp.orientation = orientation; |
|
|
2612 | rmp.origin_y = origin_y; |
|
|
2613 | rmp.origin_x = origin_x; |
|
|
2614 | rmp.random_seed = random_seed; |
|
|
2615 | rmp.total_map_hp = (uint64_t) total_map_hp; |
|
|
2616 | rmp.map_layout_style = map_layout_style; |
|
|
2617 | rmp.treasureoptions = treasureoptions; |
|
|
2618 | rmp.symmetry_used = symmetry_used; |
|
|
2619 | rmp.region = region; |
|
|
2620 | rmp.custom = custom; |
|
|
2621 | |
|
|
2622 | RETVAL = self->generate_random_map (&rmp); |
2547 | RETVAL = self->generate_random_map (&rmp); |
2623 | } |
2548 | } |
2624 | OUTPUT: |
2549 | OUTPUT: |
2625 | RETVAL |
2550 | RETVAL |
2626 | |
2551 | |
… | |
… | |
2657 | void |
2582 | void |
2658 | list () |
2583 | list () |
2659 | PPCODE: |
2584 | PPCODE: |
2660 | for_all_regions (rgn) |
2585 | for_all_regions (rgn) |
2661 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2586 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2662 | |
|
|
2663 | region *find (utf8_string name) |
|
|
2664 | PROTOTYPE: $ |
|
|
2665 | CODE: |
|
|
2666 | RETVAL = region::find (name); |
|
|
2667 | OUTPUT: RETVAL |
|
|
2668 | |
2587 | |
2669 | int specificity (region *rgn) |
2588 | int specificity (region *rgn) |
2670 | CODE: |
2589 | CODE: |
2671 | RETVAL = 0; |
2590 | RETVAL = 0; |
2672 | while (rgn = rgn->parent) |
2591 | while (rgn = rgn->parent) |
… | |
… | |
2924 | |
2843 | |
2925 | MODULE = cf PACKAGE = cf::object::thawer |
2844 | MODULE = cf PACKAGE = cf::object::thawer |
2926 | |
2845 | |
2927 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h | |
2846 | INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h | |
2928 | |
2847 | |
|
|
2848 | bool |
|
|
2849 | errors_are_fatal (bool fatal) |
|
|
2850 | CODE: |
|
|
2851 | RETVAL = object_thawer::errors_are_fatal; |
|
|
2852 | object_thawer::errors_are_fatal = fatal; |
|
|
2853 | OUTPUT: |
|
|
2854 | RETVAL |
|
|
2855 | |
2929 | SV * |
2856 | SV * |
2930 | new_from_file (char *klass, octet_string path) |
2857 | new_from_file (char *klass, octet_string path) |
2931 | CODE: |
2858 | CODE: |
2932 | object_thawer *f = new object_thawer (path); |
2859 | object_thawer *f = new object_thawer (path); |
2933 | if (!*f) |
2860 | if (!*f) |
… | |
… | |
2958 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2885 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2959 | |
2886 | |
2960 | self->skip (); |
2887 | self->skip (); |
2961 | } |
2888 | } |
2962 | |
2889 | |
|
|
2890 | MODULE = cf PACKAGE = cf::layout |
|
|
2891 | |
|
|
2892 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../random_maps/random_map.h | |
|
|
2893 | |