… | |
… | |
122 | |
122 | |
123 | return sv; |
123 | return sv; |
124 | } |
124 | } |
125 | #endif |
125 | #endif |
126 | |
126 | |
127 | static noinline utf8_string |
127 | noinline utf8_string |
128 | cfSvPVutf8_nolen (SV *sv) |
128 | cfSvPVutf8_nolen (SV *sv) |
129 | { |
129 | { |
130 | SvGETMAGIC (sv); |
130 | SvGETMAGIC (sv); |
131 | |
131 | |
132 | if (SvPOK (sv)) |
132 | if (SvPOK (sv)) |
… | |
… | |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | |
355 | |
356 | static SV * |
356 | static SV * |
357 | newSVptr (void *ptr, HV *stash, HV *hv) |
357 | newSVptr (void *ptr, HV *stash, HV *hv) |
358 | { |
358 | { |
359 | SV *sv; |
|
|
360 | |
|
|
361 | if (!ptr) |
359 | if (!ptr) |
362 | return newSV (0); |
360 | return newSV (0); |
363 | |
361 | |
364 | 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); |
365 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
363 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
366 | } |
364 | } |
367 | |
365 | |
368 | static SV * |
366 | static SV * noinline |
369 | newSVptr (void *ptr, HV *stash) |
367 | newSVptr (void *ptr, HV *stash) |
370 | { |
368 | { |
371 | return newSVptr (ptr, stash, newHV ()); |
369 | return newSVptr (ptr, stash, newHV ()); |
372 | } |
370 | } |
373 | |
371 | |
… | |
… | |
388 | return 0; |
386 | return 0; |
389 | } |
387 | } |
390 | |
388 | |
391 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
389 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
392 | |
390 | |
393 | static SV * |
391 | static SV * noinline |
394 | newSVattachable (attachable *obj, HV *stash) |
392 | newSVattachable (attachable *obj, HV *stash) |
395 | { |
393 | { |
396 | if (!obj) |
394 | if (!obj) |
397 | return newSV (0); |
395 | return newSV (0); |
398 | |
396 | |
… | |
… | |
532 | 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); } |
533 | static inline SV *to_sv (float v) { return newSVnv (v); } |
531 | static inline SV *to_sv (float v) { return newSVnv (v); } |
534 | static inline SV *to_sv (double v) { return newSVnv (v); } |
532 | static inline SV *to_sv (double v) { return newSVnv (v); } |
535 | 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); } |
536 | 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 |
537 | 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); } |
538 | 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); } |
539 | 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); } |
540 | 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); } |
541 | 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); } |
542 | 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); } |
… | |
… | |
770 | exit (EXIT_FAILURE); |
770 | exit (EXIT_FAILURE); |
771 | } |
771 | } |
772 | |
772 | |
773 | eval_pv ( |
773 | eval_pv ( |
774 | "#line 1 'cfperl init'\n" |
774 | "#line 1 'cfperl init'\n" |
775 | "use EV ();\n" |
775 | "use EV ();\n" // required by bootstrap |
776 | "use Coro ();\n" |
776 | "use Coro ();\n" // required by bootstrap |
777 | "cf->bootstrap;\n" |
777 | "cf->bootstrap;\n" // required for cf::datadir |
778 | "unshift @INC, cf::datadir ();\n" |
778 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
779 | "require cf;\n", |
779 | "require cf;\n", |
780 | 0 |
780 | 0 |
781 | ); |
781 | ); |
782 | |
782 | |
783 | if (SvTRUE (ERRSV)) |
783 | if (SvTRUE (ERRSV)) |
… | |
… | |
1491 | 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) |
1492 | |
1492 | |
1493 | 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) |
1494 | }; |
1494 | }; |
1495 | |
1495 | |
1496 | 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; ) |
1497 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1497 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1498 | |
1498 | |
1499 | static const struct { |
1499 | static const struct { |
1500 | const char *name; |
1500 | const char *name; |
1501 | int skip; |
1501 | int skip; |
… | |
… | |
1507 | # undef def |
1507 | # undef def |
1508 | }; |
1508 | }; |
1509 | |
1509 | |
1510 | AV *av = get_av ("cf::EVENT", 1); |
1510 | AV *av = get_av ("cf::EVENT", 1); |
1511 | |
1511 | |
1512 | 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; ) |
1513 | { |
1513 | { |
1514 | AV *event = newAV (); |
1514 | AV *event = newAV (); |
1515 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1515 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1516 | av_push (event, newSViv (eiv->klass)); |
1516 | av_push (event, newSViv (eiv->klass)); |
1517 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1517 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1598 | |
1598 | |
1599 | void init_anim () |
1599 | void init_anim () |
1600 | |
1600 | |
1601 | void init_globals () |
1601 | void init_globals () |
1602 | |
1602 | |
1603 | void init_experience () |
|
|
1604 | |
|
|
1605 | void init_attackmess () |
1603 | void init_attackmess () |
1606 | |
1604 | |
1607 | void init_dynamic () |
1605 | void init_dynamic () |
1608 | |
1606 | |
1609 | void load_settings () |
1607 | void load_settings () |
1610 | |
1608 | |
|
|
1609 | void reload_exp_table () |
|
|
1610 | |
1611 | void load_materials () |
1611 | void reload_materials () |
1612 | |
1612 | |
1613 | void init_uuid () |
1613 | void init_uuid () |
1614 | CODE: |
1614 | CODE: |
1615 | UUID::init (); |
1615 | UUID::init (); |
1616 | |
1616 | |
… | |
… | |
2086 | |
2086 | |
2087 | void pick_up (object *who, object *op) |
2087 | void pick_up (object *who, object *op) |
2088 | |
2088 | |
2089 | void update_object (object *op, int action) |
2089 | void update_object (object *op, int action) |
2090 | |
2090 | |
2091 | 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) |
2092 | |
2092 | |
2093 | void player_lvl_adj (object *who, object *skill = 0) |
2093 | void player_lvl_adj (object *who, object *skill = 0) |
2094 | |
2094 | |
2095 | 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) |
2096 | |
2096 | |
… | |
… | |
2536 | |
2536 | |
2537 | # worst xs function of my life |
2537 | # worst xs function of my life |
2538 | bool |
2538 | bool |
2539 | _create_random_map (\ |
2539 | _create_random_map (\ |
2540 | maptile *self,\ |
2540 | maptile *self,\ |
2541 | utf8_string wallstyle,\ |
2541 | SV *options,\ |
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,\ |
2542 | val64 total_map_hp,\ |
2573 | int map_layout_style,\ |
|
|
2574 | int treasureoptions,\ |
|
|
2575 | int symmetry_used,\ |
|
|
2576 | region *region,\ |
2543 | region *region\ |
2577 | utf8_string custom\ |
|
|
2578 | ) |
2544 | ) |
2579 | CODE: |
2545 | CODE: |
2580 | { |
2546 | { |
2581 | random_map_params rmp; |
2547 | random_map_params rmp; |
2582 | |
2548 | |
2583 | assign (rmp.wallstyle , wallstyle); |
2549 | rmp.hv = (HV *)SvREFCNT_inc_NN (SvRV (options)); |
|
|
2550 | |
2584 | assign (rmp.wall_name , wall_name); |
2551 | assign (rmp.wall_name , rmp.get_str ("wall_name")); |
2585 | assign (rmp.floorstyle , floorstyle); |
|
|
2586 | assign (rmp.monsterstyle , monsterstyle); |
2552 | assign (rmp.monsterstyle , rmp.get_str ("monsterstyle")); |
2587 | assign (rmp.treasurestyle , treasurestyle); |
|
|
2588 | assign (rmp.layoutstyle , layoutstyle); |
2553 | assign (rmp.layoutstyle , rmp.get_str ("layoutstyle")); |
2589 | assign (rmp.doorstyle , doorstyle); |
2554 | assign (rmp.doorstyle , rmp.get_str ("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); |
2555 | assign (rmp.exit_on_final_map, rmp.get_str ("exit_on_final_map")); |
2594 | |
2556 | |
2595 | 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"); |
2596 | rmp.final_map = final_map; |
2560 | rmp.final_map = rmp.get_str ("final_map"); |
2597 | rmp.this_map = this_map; |
2561 | rmp.this_map = rmp.get_str ("this_map"); |
2598 | rmp.xsize = xsize; |
2562 | rmp.xsize = rmp.get_iv ("xsize"); |
2599 | rmp.ysize = ysize; |
2563 | rmp.ysize = rmp.get_iv ("ysize"); |
2600 | rmp.expand2x = expand2x; |
2564 | rmp.expand2x = rmp.get_iv ("expand2x"); |
2601 | rmp.layoutoptions1 = layoutoptions1; |
2565 | rmp.layoutoptions1 = rmp.get_iv ("layoutoptions1"); |
2602 | rmp.layoutoptions2 = layoutoptions2; |
2566 | rmp.layoutoptions2 = rmp.get_iv ("layoutoptions2"); |
2603 | rmp.layoutoptions3 = layoutoptions3; |
2567 | rmp.layoutoptions3 = rmp.get_iv ("layoutoptions3"); |
2604 | rmp.symmetry = symmetry; |
2568 | rmp.symmetry = rmp.get_iv ("symmetry"); |
2605 | rmp.difficulty = difficulty; |
2569 | rmp.difficulty = rmp.get_iv ("difficulty"); |
2606 | rmp.difficulty_given = difficulty_given; |
2570 | rmp.difficulty_given = rmp.get_iv ("difficulty_given"); |
2607 | rmp.difficulty_increase = difficulty_increase; |
2571 | rmp.difficulty_increase = rmp.get_nv ("difficulty_increase"); |
2608 | rmp.dungeon_level = dungeon_level; |
2572 | rmp.dungeon_level = rmp.get_iv ("dungeon_level"); |
2609 | rmp.dungeon_depth = dungeon_depth; |
2573 | rmp.dungeon_depth = rmp.get_iv ("dungeon_depth"); |
2610 | rmp.decoroptions = decoroptions; |
|
|
2611 | rmp.orientation = orientation; |
2574 | rmp.orientation = rmp.get_iv ("orientation"); |
2612 | rmp.origin_y = origin_y; |
|
|
2613 | rmp.origin_x = origin_x; |
|
|
2614 | rmp.random_seed = random_seed; |
2575 | rmp.random_seed = rmp.get_uv ("random_seed"); |
2615 | rmp.total_map_hp = (uint64_t) total_map_hp; |
2576 | rmp.total_map_hp = (uint64_t)total_map_hp; |
2616 | rmp.map_layout_style = map_layout_style; |
2577 | rmp.map_layout_style = rmp.get_iv ("map_layout_style"); |
2617 | rmp.treasureoptions = treasureoptions; |
|
|
2618 | rmp.symmetry_used = symmetry_used; |
2578 | rmp.symmetry_used = rmp.get_iv ("symmetry_used"); |
2619 | rmp.region = region; |
2579 | rmp.region = region; |
2620 | rmp.custom = custom; |
|
|
2621 | |
2580 | |
2622 | RETVAL = self->generate_random_map (&rmp); |
2581 | RETVAL = self->generate_random_map (&rmp); |
2623 | } |
2582 | } |
2624 | OUTPUT: |
2583 | OUTPUT: |
2625 | RETVAL |
2584 | RETVAL |