… | |
… | |
626 | |
626 | |
627 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
627 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
628 | |
628 | |
629 | const char *argv[] = { |
629 | const char *argv[] = { |
630 | settings.argv [0], |
630 | settings.argv [0], |
631 | "-e" |
631 | "-e0" |
632 | "use EV; use Coro;" // required for bootstrap |
|
|
633 | "cf->bootstrap;" // required for datadir :*> |
|
|
634 | "unshift @INC, cf::datadir ();" |
|
|
635 | "require cf;" |
|
|
636 | }; |
632 | }; |
637 | |
633 | |
638 | if (perl_parse (perl, xs_init, 2, (char **)argv, environ) |
634 | if (perl_parse (perl, xs_init, 2, (char **)argv, environ) |
639 | || perl_run (perl)) |
635 | || perl_run (perl)) |
640 | { |
636 | { |
641 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
637 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
642 | exit (EXIT_FAILURE); |
638 | exit (EXIT_FAILURE); |
643 | } |
639 | } |
644 | |
640 | |
|
|
641 | eval_pv ( |
|
|
642 | "#line 1 'cfperl init'\n" |
|
|
643 | "use EV ();\n" |
|
|
644 | "use Coro ();\n" |
|
|
645 | "cf->bootstrap;\n" |
|
|
646 | "unshift @INC, cf::datadir ();\n" |
|
|
647 | "require cf;\n", |
|
|
648 | 0 |
|
|
649 | ); |
|
|
650 | |
|
|
651 | if (SvTRUE (ERRSV)) |
645 | { |
652 | { |
646 | dSP; |
653 | printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); |
647 | |
654 | exit (EXIT_FAILURE); |
648 | PUSHMARK (SP); |
|
|
649 | PUTBACK; |
|
|
650 | call_pv ("cf::init", G_DISCARD | G_VOID); |
|
|
651 | } |
655 | } |
652 | } |
656 | } |
653 | |
657 | |
654 | void cfperl_main () |
658 | void cfperl_main () |
655 | { |
659 | { |
656 | dSP; |
660 | dSP; |
… | |
… | |
1521 | f (GvGP (gv)->gp_cv); |
1525 | f (GvGP (gv)->gp_cv); |
1522 | GvCVGEN (gv) = 0; |
1526 | GvCVGEN (gv) = 0; |
1523 | GvMULTI_off (gv); |
1527 | GvMULTI_off (gv); |
1524 | # undef f |
1528 | # undef f |
1525 | |
1529 | |
1526 | |
|
|
1527 | void _connect_to_perl () |
1530 | void _connect_to_perl () |
1528 | |
1531 | |
1529 | void _recalc_want () |
1532 | void _recalc_want () |
1530 | |
1533 | |
|
|
1534 | # not used by default anymore |
1531 | void _global_reattach () |
1535 | void _global_reattach () |
1532 | CODE: |
1536 | CODE: |
1533 | { |
1537 | { |
1534 | // reattach to all attachable objects in the game. |
1538 | // reattach to all attachable objects in the game. |
1535 | for_all_clients (ns) |
1539 | for_all_clients (ns) |
… | |
… | |
1578 | len -= 3; |
1582 | len -= 3; |
1579 | } |
1583 | } |
1580 | |
1584 | |
1581 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1585 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1582 | } |
1586 | } |
|
|
1587 | |
|
|
1588 | void init_anim () |
|
|
1589 | |
|
|
1590 | void init_globals () |
|
|
1591 | |
|
|
1592 | void init_experience () |
|
|
1593 | |
|
|
1594 | void init_attackmess () |
|
|
1595 | |
|
|
1596 | void init_dynamic () |
|
|
1597 | |
|
|
1598 | void init_block () |
|
|
1599 | |
|
|
1600 | void load_settings () |
|
|
1601 | |
|
|
1602 | void load_materials () |
|
|
1603 | |
|
|
1604 | void init_uuid () |
|
|
1605 | CODE: |
|
|
1606 | UUID::init (); |
|
|
1607 | |
|
|
1608 | void init_signals () |
|
|
1609 | |
|
|
1610 | void init_commands () |
|
|
1611 | |
|
|
1612 | void init_skills () |
|
|
1613 | |
|
|
1614 | void init_beforeplay () |
1583 | |
1615 | |
1584 | void evthread_start (int aiofd) |
1616 | void evthread_start (int aiofd) |
1585 | |
1617 | |
1586 | void cede_to_tick () |
1618 | void cede_to_tick () |
1587 | CODE: |
1619 | CODE: |
… | |
… | |
1725 | #if _POSIX_MEMLOCK |
1757 | #if _POSIX_MEMLOCK |
1726 | |
1758 | |
1727 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1759 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1728 | INIT: |
1760 | INIT: |
1729 | #if __GLIBC__ |
1761 | #if __GLIBC__ |
|
|
1762 | mallopt (M_TOP_PAD, 1024 * 1024); |
|
|
1763 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
|
|
1764 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1730 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1765 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1731 | #endif |
1766 | #endif |
1732 | |
1767 | |
1733 | int munlockall () |
1768 | int munlockall () |
1734 | |
1769 | |
… | |
… | |
2392 | } |
2427 | } |
2393 | |
2428 | |
2394 | void |
2429 | void |
2395 | maptile::create_region_treasure () |
2430 | maptile::create_region_treasure () |
2396 | CODE: |
2431 | CODE: |
2397 | { |
|
|
2398 | object *op = object::create (); |
|
|
2399 | op->type = FLOOR; |
|
|
2400 | op->map = THIS; |
|
|
2401 | |
|
|
2402 | for (int x = 0; x < THIS->width; ++x) |
2432 | for (int x = 0; x < THIS->width; ++x) |
2403 | for (int y = 0; y < THIS->height; ++y) |
2433 | for (int y = 0; y < THIS->height; ++y) |
2404 | { |
2434 | { |
2405 | region *rgn = THIS->region (x, y); |
2435 | region *rgn = THIS->region (x, y); |
2406 | |
2436 | |
2407 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
2437 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
|
|
2438 | if (object *op = THIS->at (x, y).top) |
2408 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2439 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2409 | { |
|
|
2410 | op->x = x; |
|
|
2411 | op->y = y; |
|
|
2412 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2440 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2413 | } |
|
|
2414 | } |
2441 | } |
2415 | |
|
|
2416 | op->destroy (); |
|
|
2417 | } |
|
|
2418 | |
2442 | |
2419 | int out_of_map (maptile *map, int x, int y) |
2443 | int out_of_map (maptile *map, int x, int y) |
2420 | |
2444 | |
2421 | void |
2445 | void |
2422 | trigger (maptile *map, long connection, bool state = true) |
2446 | trigger (maptile *map, long connection, bool state = true) |