… | |
… | |
352 | #endif |
352 | #endif |
353 | |
353 | |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | |
355 | |
356 | static SV * |
356 | static SV * |
357 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
357 | newSVptr (void *ptr, HV *stash, HV *hv) |
358 | { |
358 | { |
359 | SV *sv; |
359 | SV *sv; |
360 | |
360 | |
361 | if (!ptr) |
361 | if (!ptr) |
362 | return newSV (0); |
362 | return newSV (0); |
363 | |
363 | |
364 | 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); |
365 | 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 ()); |
366 | } |
372 | } |
367 | |
373 | |
368 | static int |
374 | static int |
369 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
375 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
370 | { |
376 | { |
… | |
… | |
764 | exit (EXIT_FAILURE); |
770 | exit (EXIT_FAILURE); |
765 | } |
771 | } |
766 | |
772 | |
767 | eval_pv ( |
773 | eval_pv ( |
768 | "#line 1 'cfperl init'\n" |
774 | "#line 1 'cfperl init'\n" |
769 | "use EV ();\n" |
775 | "use EV ();\n" // required by bootstrap |
770 | "use Coro ();\n" |
776 | "use Coro ();\n" // required by bootstrap |
771 | "cf->bootstrap;\n" |
777 | "cf->bootstrap;\n" // required for cf::datadir |
772 | "unshift @INC, cf::datadir ();\n" |
778 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
773 | "require cf;\n", |
779 | "require cf;\n", |
774 | 0 |
780 | 0 |
775 | ); |
781 | ); |
776 | |
782 | |
777 | if (SvTRUE (ERRSV)) |
783 | if (SvTRUE (ERRSV)) |
… | |
… | |
1450 | # undef def |
1456 | # undef def |
1451 | # define def(uc, flags) const_iv (SK_ ## uc) |
1457 | # define def(uc, flags) const_iv (SK_ ## uc) |
1452 | # include "skillinc.h" |
1458 | # include "skillinc.h" |
1453 | # undef def |
1459 | # undef def |
1454 | |
1460 | |
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) |
1461 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1459 | |
1462 | |
1460 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1463 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1461 | |
1464 | |
1462 | const_iv (MAX_TIME) |
1465 | const_iv (MAX_TIME) |
… | |
… | |
1488 | 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) |
1489 | |
1492 | |
1490 | 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) |
1491 | }; |
1494 | }; |
1492 | |
1495 | |
1493 | 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; ) |
1494 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1497 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1495 | |
1498 | |
1496 | static const struct { |
1499 | static const struct { |
1497 | const char *name; |
1500 | const char *name; |
1498 | int skip; |
1501 | int skip; |
… | |
… | |
1504 | # undef def |
1507 | # undef def |
1505 | }; |
1508 | }; |
1506 | |
1509 | |
1507 | AV *av = get_av ("cf::EVENT", 1); |
1510 | AV *av = get_av ("cf::EVENT", 1); |
1508 | |
1511 | |
1509 | 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; ) |
1510 | { |
1513 | { |
1511 | AV *event = newAV (); |
1514 | AV *event = newAV (); |
1512 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1515 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1513 | av_push (event, newSViv (eiv->klass)); |
1516 | av_push (event, newSViv (eiv->klass)); |
1514 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1517 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
2083 | |
2086 | |
2084 | void pick_up (object *who, object *op) |
2087 | void pick_up (object *who, object *op) |
2085 | |
2088 | |
2086 | void update_object (object *op, int action) |
2089 | void update_object (object *op, int action) |
2087 | |
2090 | |
2088 | 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) |
2089 | |
2092 | |
2090 | void player_lvl_adj (object *who, object *skill = 0) |
2093 | void player_lvl_adj (object *who, object *skill = 0) |
2091 | |
2094 | |
2092 | 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) |
2093 | |
2096 | |
… | |
… | |
2458 | if (oblinkpt *obp = map->find_link (connection)) |
2461 | if (oblinkpt *obp = map->find_link (connection)) |
2459 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2462 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2460 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2463 | XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); |
2461 | |
2464 | |
2462 | void |
2465 | void |
2463 | normalise (maptile *map, int x, int y, int dir = 0) |
2466 | xy_normalise (maptile *map, int x, int y, int dir = 0) |
2464 | PPCODE: |
2467 | PPCODE: |
2465 | { |
2468 | { |
2466 | mapxy pos (map, x, y); |
2469 | mapxy pos (map, x, y); |
2467 | if (!pos.move (dir).normalise ()) |
2470 | if (!pos.move (dir).normalise ()) |
2468 | XSRETURN_EMPTY; |
2471 | XSRETURN_EMPTY; |
… | |
… | |
2655 | list () |
2658 | list () |
2656 | PPCODE: |
2659 | PPCODE: |
2657 | for_all_regions (rgn) |
2660 | for_all_regions (rgn) |
2658 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2661 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2659 | |
2662 | |
2660 | region *find (utf8_string name) |
|
|
2661 | PROTOTYPE: $ |
|
|
2662 | CODE: |
|
|
2663 | RETVAL = region::find (name); |
|
|
2664 | OUTPUT: RETVAL |
|
|
2665 | |
|
|
2666 | int specificity (region *rgn) |
2663 | int specificity (region *rgn) |
2667 | CODE: |
2664 | CODE: |
2668 | RETVAL = 0; |
2665 | RETVAL = 0; |
2669 | while (rgn = rgn->parent) |
2666 | while (rgn = rgn->parent) |
2670 | RETVAL++; |
2667 | RETVAL++; |