… | |
… | |
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, |
89 | *stash_ext_map_world; |
90 | *stash_ext_map_world; |
90 | |
91 | |
91 | static SV |
92 | static SV |
92 | *cv_cf_do_invoke, |
93 | *cv_cf_do_invoke, |
93 | *cv_cf__can_merge, |
94 | *cv_cf__can_merge, |
… | |
… | |
122 | |
123 | |
123 | return sv; |
124 | return sv; |
124 | } |
125 | } |
125 | #endif |
126 | #endif |
126 | |
127 | |
127 | static noinline utf8_string |
128 | noinline utf8_string |
128 | cfSvPVutf8_nolen (SV *sv) |
129 | cfSvPVutf8_nolen (SV *sv) |
129 | { |
130 | { |
130 | SvGETMAGIC (sv); |
131 | SvGETMAGIC (sv); |
131 | |
132 | |
132 | if (SvPOK (sv)) |
133 | if (SvPOK (sv)) |
… | |
… | |
352 | #endif |
353 | #endif |
353 | |
354 | |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | |
356 | |
356 | static SV * |
357 | static SV * |
357 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
358 | newSVptr (void *ptr, HV *stash, HV *hv) |
358 | { |
359 | { |
359 | SV *sv; |
|
|
360 | |
|
|
361 | if (!ptr) |
360 | if (!ptr) |
362 | return newSV (0); |
361 | return newSV (0); |
363 | |
362 | |
364 | 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); |
365 | 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 ()); |
366 | } |
371 | } |
367 | |
372 | |
368 | static int |
373 | static int |
369 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
374 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
370 | { |
375 | { |
… | |
… | |
382 | return 0; |
387 | return 0; |
383 | } |
388 | } |
384 | |
389 | |
385 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
390 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
386 | |
391 | |
387 | static SV * |
392 | static SV * noinline |
388 | newSVattachable (attachable *obj, HV *stash) |
393 | newSVattachable (attachable *obj, HV *stash) |
389 | { |
394 | { |
390 | if (!obj) |
395 | if (!obj) |
391 | return newSV (0); |
396 | return newSV (0); |
392 | |
397 | |
… | |
… | |
526 | 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); } |
527 | static inline SV *to_sv (float v) { return newSVnv (v); } |
532 | static inline SV *to_sv (float v) { return newSVnv (v); } |
528 | static inline SV *to_sv (double v) { return newSVnv (v); } |
533 | static inline SV *to_sv (double v) { return newSVnv (v); } |
529 | 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); } |
530 | 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 |
531 | 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); } |
532 | 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); } |
533 | 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); } |
534 | 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); } |
535 | 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); } |
536 | 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); } |
537 | 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); } |
538 | |
546 | |
539 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
547 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
540 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
548 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
541 | |
549 | |
542 | 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 ()); } |
… | |
… | |
588 | 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"); } |
589 | 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"); } |
590 | 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"); } |
591 | 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"); } |
592 | 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"); } |
593 | 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"); } |
594 | 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" ); } |
595 | |
604 | |
596 | //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)]; } |
597 | 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)); } |
… | |
… | |
764 | exit (EXIT_FAILURE); |
773 | exit (EXIT_FAILURE); |
765 | } |
774 | } |
766 | |
775 | |
767 | eval_pv ( |
776 | eval_pv ( |
768 | "#line 1 'cfperl init'\n" |
777 | "#line 1 'cfperl init'\n" |
769 | "use EV ();\n" |
778 | "use EV ();\n" // required by bootstrap |
770 | "use Coro ();\n" |
779 | "use Coro ();\n" // required by bootstrap |
771 | "cf->bootstrap;\n" |
780 | "cf->bootstrap;\n" // required for cf::datadir |
772 | "unshift @INC, cf::datadir ();\n" |
781 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
773 | "require cf;\n", |
782 | "require cf;\n", |
774 | 0 |
783 | 0 |
775 | ); |
784 | ); |
776 | |
785 | |
777 | if (SvTRUE (ERRSV)) |
786 | if (SvTRUE (ERRSV)) |
… | |
… | |
1391 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1400 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1392 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1401 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1393 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1402 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1394 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1403 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1395 | 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); |
1396 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1406 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1397 | |
1407 | |
1398 | 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); |
1399 | 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); |
1400 | 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); |
… | |
… | |
1450 | # undef def |
1460 | # undef def |
1451 | # define def(uc, flags) const_iv (SK_ ## uc) |
1461 | # define def(uc, flags) const_iv (SK_ ## uc) |
1452 | # include "skillinc.h" |
1462 | # include "skillinc.h" |
1453 | # undef def |
1463 | # undef def |
1454 | |
1464 | |
1455 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
|
|
1456 | const_iv (logBacktrace) |
|
|
1457 | |
|
|
1458 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1465 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1459 | |
1466 | |
1460 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1467 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1461 | |
1468 | |
1462 | const_iv (MAX_TIME) |
1469 | const_iv (MAX_TIME) |
… | |
… | |
1488 | 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) |
1489 | |
1496 | |
1490 | 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) |
1491 | }; |
1498 | }; |
1492 | |
1499 | |
1493 | 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; ) |
1494 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1501 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1495 | |
1502 | |
1496 | static const struct { |
1503 | static const struct { |
1497 | const char *name; |
1504 | const char *name; |
1498 | int skip; |
1505 | int skip; |
… | |
… | |
1504 | # undef def |
1511 | # undef def |
1505 | }; |
1512 | }; |
1506 | |
1513 | |
1507 | AV *av = get_av ("cf::EVENT", 1); |
1514 | AV *av = get_av ("cf::EVENT", 1); |
1508 | |
1515 | |
1509 | 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; ) |
1510 | { |
1517 | { |
1511 | AV *event = newAV (); |
1518 | AV *event = newAV (); |
1512 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1519 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1513 | av_push (event, newSViv (eiv->klass)); |
1520 | av_push (event, newSViv (eiv->klass)); |
1514 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1521 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1595 | |
1602 | |
1596 | void init_anim () |
1603 | void init_anim () |
1597 | |
1604 | |
1598 | void init_globals () |
1605 | void init_globals () |
1599 | |
1606 | |
1600 | void init_experience () |
|
|
1601 | |
|
|
1602 | void init_attackmess () |
1607 | void init_attackmess () |
1603 | |
1608 | |
1604 | void init_dynamic () |
1609 | void init_dynamic () |
1605 | |
1610 | |
1606 | void load_settings () |
1611 | void load_settings () |
1607 | |
1612 | |
|
|
1613 | void reload_exp_table () |
|
|
1614 | |
1608 | void load_materials () |
1615 | void reload_materials () |
1609 | |
1616 | |
1610 | void init_uuid () |
1617 | void init_uuid () |
1611 | CODE: |
1618 | CODE: |
1612 | UUID::init (); |
1619 | UUID::init (); |
1613 | |
1620 | |
… | |
… | |
1883 | CODE: |
1890 | CODE: |
1884 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1891 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1885 | OUTPUT: |
1892 | OUTPUT: |
1886 | RETVAL |
1893 | RETVAL |
1887 | |
1894 | |
|
|
1895 | bool should_invoke (attachable *obj, int event) |
|
|
1896 | CODE: |
|
|
1897 | RETVAL = obj->should_invoke ((event_type)event); |
|
|
1898 | OUTPUT: RETVAL |
|
|
1899 | |
1888 | void |
1900 | void |
1889 | debug_trace (attachable *obj, bool on = true) |
1901 | debug_trace (attachable *obj, bool on = true) |
1890 | CODE: |
1902 | CODE: |
1891 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1903 | obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; |
1892 | if (on) |
1904 | if (on) |
… | |
… | |
2078 | |
2090 | |
2079 | void pick_up (object *who, object *op) |
2091 | void pick_up (object *who, object *op) |
2080 | |
2092 | |
2081 | void update_object (object *op, int action) |
2093 | void update_object (object *op, int action) |
2082 | |
2094 | |
2083 | 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) |
2084 | |
2096 | |
2085 | void player_lvl_adj (object *who, object *skill = 0) |
2097 | void player_lvl_adj (object *who, object *skill = 0) |
2086 | |
2098 | |
2087 | 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) |
2088 | |
2100 | |
… | |
… | |
2453 | if (oblinkpt *obp = map->find_link (connection)) |
2465 | if (oblinkpt *obp = map->find_link (connection)) |
2454 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2466 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2455 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2467 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2456 | |
2468 | |
2457 | void |
2469 | void |
2458 | get_map_flags (maptile *map, int x, int y) |
2470 | xy_normalise (maptile *map, int x, int y, int dir = 0) |
2459 | PPCODE: |
2471 | PPCODE: |
2460 | { |
2472 | { |
2461 | maptile *nmap = 0; |
2473 | mapxy pos (map, x, y); |
2462 | I16 nx = 0, ny = 0; |
2474 | if (!pos.move (dir).normalise ()) |
|
|
2475 | XSRETURN_EMPTY; |
2463 | |
2476 | |
2464 | PUTBACK; |
|
|
2465 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2466 | SPAGAIN; |
|
|
2467 | |
|
|
2468 | EXTEND (SP, 4); |
2477 | EXTEND (SP, 3); |
2469 | PUSHs (sv_2mortal (newSViv (flags))); |
|
|
2470 | |
|
|
2471 | if (GIMME_V == G_ARRAY) |
|
|
2472 | { |
|
|
2473 | PUSHs (sv_2mortal (to_sv (nmap))); |
2478 | PUSHs (sv_2mortal (to_sv (pos.m))); |
2474 | PUSHs (sv_2mortal (newSViv (nx))); |
2479 | PUSHs (sv_2mortal (to_sv (pos.x))); |
2475 | PUSHs (sv_2mortal (newSViv (ny))); |
2480 | PUSHs (sv_2mortal (to_sv (pos.y))); |
2476 | } |
|
|
2477 | } |
2481 | } |
2478 | |
2482 | |
2479 | mapspace * |
2483 | mapspace * |
2480 | ms (maptile *map, unsigned int x, unsigned int y) |
2484 | ms (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2481 | PROTOTYPE: $$$ |
2485 | PROTOTYPE: $$$;$ |
2482 | CODE: |
2486 | CODE: |
2483 | { |
2487 | { |
2484 | maptile *nmap = 0; |
2488 | mapxy pos (map, x, y); |
2485 | I16 nx, ny; |
2489 | if (!pos.move (dir).normalise ()) |
2486 | |
|
|
2487 | PUTBACK; |
|
|
2488 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2489 | SPAGAIN; |
|
|
2490 | |
|
|
2491 | if (!nmap) |
|
|
2492 | XSRETURN_UNDEF; |
2490 | XSRETURN_UNDEF; |
2493 | |
2491 | |
2494 | RETVAL = &nmap->at (nx, ny); |
2492 | RETVAL = &*pos; |
2495 | } |
2493 | } |
2496 | OUTPUT: |
2494 | OUTPUT: |
2497 | RETVAL |
2495 | RETVAL |
2498 | |
2496 | |
2499 | void |
2497 | void |
2500 | at (maptile *map, unsigned int x, unsigned int y) |
2498 | at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2501 | PROTOTYPE: $$$ |
2499 | PROTOTYPE: $$$;$ |
2502 | PPCODE: |
2500 | PPCODE: |
2503 | { |
2501 | mapxy pos (map, x, y); |
2504 | maptile *nmap = 0; |
2502 | if (pos.move (dir).normalise ()) |
2505 | I16 nx, ny; |
|
|
2506 | |
|
|
2507 | PUTBACK; |
|
|
2508 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2509 | SPAGAIN; |
|
|
2510 | |
|
|
2511 | if (nmap) |
|
|
2512 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2503 | for (object *o = pos->bot; o; o = o->above) |
2513 | XPUSHs (sv_2mortal (to_sv (o))); |
2504 | XPUSHs (sv_2mortal (to_sv (o))); |
2514 | } |
|
|
2515 | |
2505 | |
2516 | SV * |
2506 | SV * |
2517 | bot_at (maptile *map, unsigned int x, unsigned int y) |
2507 | bot_at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2518 | PROTOTYPE: $$$ |
2508 | PROTOTYPE: $$$;$ |
2519 | ALIAS: |
2509 | ALIAS: |
2520 | top_at = 1 |
2510 | top_at = 1 |
2521 | flags_at = 2 |
2511 | flags_at = 2 |
2522 | light_at = 3 |
2512 | light_at = 3 |
2523 | move_block_at = 4 |
2513 | move_block_at = 4 |
2524 | move_slow_at = 5 |
2514 | move_slow_at = 5 |
2525 | move_on_at = 6 |
2515 | move_on_at = 6 |
2526 | move_off_at = 7 |
2516 | move_off_at = 7 |
2527 | CODE: |
2517 | CODE: |
2528 | { |
2518 | { |
2529 | sint16 nx = x; |
2519 | mapxy pos (map, x, y); |
2530 | sint16 ny = y; |
2520 | if (!pos.move (dir).normalise ()) |
2531 | |
|
|
2532 | if (!xy_normalise (map, nx, ny)) |
|
|
2533 | XSRETURN_UNDEF; |
2521 | XSRETURN_UNDEF; |
2534 | |
2522 | |
2535 | mapspace &ms = map->at (nx, ny); |
2523 | mapspace &ms = *pos; |
2536 | |
2524 | |
2537 | ms.update (); |
2525 | ms.update (); |
2538 | |
2526 | |
2539 | switch (ix) |
2527 | switch (ix) |
2540 | { |
2528 | { |
… | |
… | |
2550 | } |
2538 | } |
2551 | OUTPUT: RETVAL |
2539 | OUTPUT: RETVAL |
2552 | |
2540 | |
2553 | # worst xs function of my life |
2541 | # worst xs function of my life |
2554 | bool |
2542 | bool |
2555 | _create_random_map (\ |
2543 | _create_random_map (maptile *self, SV *options) |
2556 | maptile *self,\ |
|
|
2557 | utf8_string wallstyle,\ |
|
|
2558 | utf8_string wall_name,\ |
|
|
2559 | utf8_string floorstyle,\ |
|
|
2560 | utf8_string monsterstyle,\ |
|
|
2561 | utf8_string treasurestyle,\ |
|
|
2562 | utf8_string layoutstyle,\ |
|
|
2563 | utf8_string doorstyle,\ |
|
|
2564 | utf8_string decorstyle,\ |
|
|
2565 | utf8_string miningstyle,\ |
|
|
2566 | utf8_string origin_map,\ |
|
|
2567 | utf8_string final_map,\ |
|
|
2568 | utf8_string exitstyle,\ |
|
|
2569 | utf8_string this_map,\ |
|
|
2570 | utf8_string exit_on_final_map,\ |
|
|
2571 | int xsize,\ |
|
|
2572 | int ysize,\ |
|
|
2573 | int expand2x,\ |
|
|
2574 | int layoutoptions1,\ |
|
|
2575 | int layoutoptions2,\ |
|
|
2576 | int layoutoptions3,\ |
|
|
2577 | int symmetry,\ |
|
|
2578 | int difficulty,\ |
|
|
2579 | int difficulty_given,\ |
|
|
2580 | float difficulty_increase,\ |
|
|
2581 | int dungeon_level,\ |
|
|
2582 | int dungeon_depth,\ |
|
|
2583 | int decoroptions,\ |
|
|
2584 | int orientation,\ |
|
|
2585 | int origin_y,\ |
|
|
2586 | int origin_x,\ |
|
|
2587 | U32 random_seed,\ |
|
|
2588 | val64 total_map_hp,\ |
|
|
2589 | int map_layout_style,\ |
|
|
2590 | int treasureoptions,\ |
|
|
2591 | int symmetry_used,\ |
|
|
2592 | region *region,\ |
|
|
2593 | utf8_string custom\ |
|
|
2594 | ) |
|
|
2595 | CODE: |
2544 | CODE: |
2596 | { |
2545 | { |
2597 | random_map_params rmp; |
2546 | random_map_params rmp ((HV *)SvRV (options)); |
2598 | |
|
|
2599 | assign (rmp.wallstyle , wallstyle); |
|
|
2600 | assign (rmp.wall_name , wall_name); |
|
|
2601 | assign (rmp.floorstyle , floorstyle); |
|
|
2602 | assign (rmp.monsterstyle , monsterstyle); |
|
|
2603 | assign (rmp.treasurestyle , treasurestyle); |
|
|
2604 | assign (rmp.layoutstyle , layoutstyle); |
|
|
2605 | assign (rmp.doorstyle , doorstyle); |
|
|
2606 | assign (rmp.decorstyle , decorstyle); |
|
|
2607 | assign (rmp.miningstyle , miningstyle); |
|
|
2608 | assign (rmp.exitstyle , exitstyle); |
|
|
2609 | assign (rmp.exit_on_final_map, exit_on_final_map); |
|
|
2610 | |
|
|
2611 | rmp.origin_map = origin_map; |
|
|
2612 | rmp.final_map = final_map; |
|
|
2613 | rmp.this_map = this_map; |
|
|
2614 | rmp.xsize = xsize; |
|
|
2615 | rmp.ysize = ysize; |
|
|
2616 | rmp.expand2x = expand2x; |
|
|
2617 | rmp.layoutoptions1 = layoutoptions1; |
|
|
2618 | rmp.layoutoptions2 = layoutoptions2; |
|
|
2619 | rmp.layoutoptions3 = layoutoptions3; |
|
|
2620 | rmp.symmetry = symmetry; |
|
|
2621 | rmp.difficulty = difficulty; |
|
|
2622 | rmp.difficulty_given = difficulty_given; |
|
|
2623 | rmp.difficulty_increase = difficulty_increase; |
|
|
2624 | rmp.dungeon_level = dungeon_level; |
|
|
2625 | rmp.dungeon_depth = dungeon_depth; |
|
|
2626 | rmp.decoroptions = decoroptions; |
|
|
2627 | rmp.orientation = orientation; |
|
|
2628 | rmp.origin_y = origin_y; |
|
|
2629 | rmp.origin_x = origin_x; |
|
|
2630 | rmp.random_seed = random_seed; |
|
|
2631 | rmp.total_map_hp = (uint64_t) total_map_hp; |
|
|
2632 | rmp.map_layout_style = map_layout_style; |
|
|
2633 | rmp.treasureoptions = treasureoptions; |
|
|
2634 | rmp.symmetry_used = symmetry_used; |
|
|
2635 | rmp.region = region; |
|
|
2636 | rmp.custom = custom; |
|
|
2637 | |
|
|
2638 | RETVAL = self->generate_random_map (&rmp); |
2547 | RETVAL = self->generate_random_map (&rmp); |
2639 | } |
2548 | } |
2640 | OUTPUT: |
2549 | OUTPUT: |
2641 | RETVAL |
2550 | RETVAL |
2642 | |
2551 | |
… | |
… | |
2673 | void |
2582 | void |
2674 | list () |
2583 | list () |
2675 | PPCODE: |
2584 | PPCODE: |
2676 | for_all_regions (rgn) |
2585 | for_all_regions (rgn) |
2677 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2586 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2678 | |
|
|
2679 | region *find (utf8_string name) |
|
|
2680 | PROTOTYPE: $ |
|
|
2681 | CODE: |
|
|
2682 | RETVAL = region::find (name); |
|
|
2683 | OUTPUT: RETVAL |
|
|
2684 | |
2587 | |
2685 | int specificity (region *rgn) |
2588 | int specificity (region *rgn) |
2686 | CODE: |
2589 | CODE: |
2687 | RETVAL = 0; |
2590 | RETVAL = 0; |
2688 | while (rgn = rgn->parent) |
2591 | while (rgn = rgn->parent) |
… | |
… | |
2982 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2885 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2983 | |
2886 | |
2984 | self->skip (); |
2887 | self->skip (); |
2985 | } |
2888 | } |
2986 | |
2889 | |
|
|
2890 | MODULE = cf PACKAGE = cf::layout |
|
|
2891 | |
|
|
2892 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../random_maps/random_map.h | |
|
|
2893 | |