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