ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.369 by root, Wed Apr 14 02:31:24 2010 UTC vs.
Revision 1.375 by root, Sun Apr 18 05:08:14 2010 UTC

52#include <XSUB.h> 52#include <XSUB.h>
53 53
54#include "CoroAPI.h" 54#include "CoroAPI.h"
55#include "perlxsi.c" 55#include "perlxsi.c"
56 56
57extern sint64 *levels; // the experience table
58
59typedef object_thawer &object_thawer_ref; 57typedef object_thawer &object_thawer_ref;
60typedef object_freezer &object_freezer_ref; 58typedef object_freezer &object_freezer_ref;
61 59
62typedef std::string std__string; 60typedef std::string std__string;
63 61
479 || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap 477 || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap
480 && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap 478 && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap
481 && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap 479 && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap
482 && !sv_derived_from (sv, "cf::object"))) 480 && !sv_derived_from (sv, "cf::object")))
483 croak ("object of type cf::object expected"); 481 croak ("object of type cf::object expected");
482
483 return SvPTR_nc (sv);
484}
485
486static long noinline
487SvPTR_ornull_maptile (SV *sv)
488{
489 if (expect_false (!SvOK (sv))) return 0;
490
491 if (!SvROK (sv)
492 || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap
493 && !sv_derived_from (sv, "cf::map")))
494 croak ("object of type cf::map expected");
484 495
485 return SvPTR_nc (sv); 496 return SvPTR_nc (sv);
486} 497}
487 498
488static long noinline 499static long noinline
565static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } 576static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); }
566static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } 577static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); }
567static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } 578static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); }
568static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 579static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
569static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 580static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); }
570static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } 581static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); }
571static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } 582static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); }
572static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } 583static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); }
584static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull_maptile (sv); }
573static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } 585static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); }
574static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull (sv, "cf::map"); }
575static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } 586static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); }
576static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 587static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
577static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } 588static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); }
578static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } 589static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); }
579static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } 590static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); }
695template<class type> 706template<class type>
696static void noinline 707static void noinline
697cf_obj_to (SV *arg, type &var) 708cf_obj_to (SV *arg, type &var)
698{ 709{
699 sv_to (arg, var); 710 sv_to (arg, var);
700 if (!var) 711 if (expect_false (!var))
701 croak ("must not pass invalid/null cf_obj here"); 712 croak ("must not pass invalid/null cf_obj here");
702} 713}
703 714
704template<class object> 715template<class object>
705static void noinline 716static void noinline
706cf_obj_ornull_to (SV *arg, object *&var) 717cf_obj_ornull_to (SV *arg, object *&var)
707{ 718{
708 if (SvOK (arg)) 719 if (SvOK (arg))
709 { 720 {
710 sv_to (arg, var); 721 sv_to (arg, var);
711 if (!var) 722 if (expect_false (!var))
712 croak ("unable to convert perl object to C++ object"); 723 croak ("unable to convert perl object to C++ object");
713 } 724 }
714 else 725 else
715 var = 0; 726 var = 0;
716} 727}
1799 1810
1800int random_roll (int min, int max, object *op, int goodbad); 1811int random_roll (int min, int max, object *op, int goodbad);
1801 1812
1802const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1813const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1803 1814
1804int
1805exp_to_level (val64 exp) 1815int exp_to_level (val64 exp)
1806 CODE:
1807{
1808 int i = 0;
1809 1816
1810 RETVAL = settings.max_level;
1811
1812 for (i = 1; i <= settings.max_level; i++)
1813 {
1814 if (levels[i] > exp)
1815 {
1816 RETVAL = i - 1;
1817 break;
1818 }
1819 }
1820}
1821 OUTPUT: RETVAL
1822
1823val64
1824level_to_min_exp (int level) 1817val64 level_to_min_exp (int level)
1825 CODE:
1826 if (level > settings.max_level)
1827 RETVAL = levels[settings.max_level];
1828 else if (level < 1)
1829 RETVAL = 0;
1830 else
1831 RETVAL = levels[level];
1832 OUTPUT: RETVAL
1833 1818
1834SV * 1819SV *
1835resistance_to_string (int atnr) 1820resistance_to_string (int atnr)
1836 CODE: 1821 CODE:
1837 if (atnr >= 0 && atnr < NROFATTACKS) 1822 if (atnr >= 0 && atnr < NROFATTACKS)
2028} 2013}
2029 OUTPUT: 2014 OUTPUT:
2030 RETVAL 2015 RETVAL
2031 2016
2032object *find_best_object_match (object *op, utf8_string match) 2017object *find_best_object_match (object *op, utf8_string match)
2033
2034object *find_marked_object (object *op)
2035
2036int need_identify (object *obj);
2037 2018
2038int apply_shop_mat (object *shop_mat, object *op); 2019int apply_shop_mat (object *shop_mat, object *op);
2039 2020
2040int move (object *op, int dir, object *originator = op) 2021int move (object *op, int dir, object *originator = op)
2041 CODE: 2022 CODE:
2954 sv_to (sv, self); 2935 sv_to (sv, self);
2955 delete self; 2936 delete self;
2956 2937
2957MODULE = cf PACKAGE = cf::object::thawer 2938MODULE = cf PACKAGE = cf::object::thawer
2958 2939
2959INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/cfperl.h | 2940INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h |
2941
2942bool
2943errors_are_fatal (bool fatal)
2944 CODE:
2945 RETVAL = object_thawer::errors_are_fatal;
2946 object_thawer::errors_are_fatal = fatal;
2947 OUTPUT:
2948 RETVAL
2960 2949
2961SV * 2950SV *
2962new_from_file (char *klass, octet_string path) 2951new_from_file (char *klass, octet_string path)
2963 CODE: 2952 CODE:
2964 object_thawer *f = new object_thawer (path); 2953 object_thawer *f = new object_thawer (path);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines