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.309 by root, Thu Dec 4 03:48:19 2008 UTC vs.
Revision 1.314 by root, Thu Jan 1 20:49:48 2009 UTC

158 SvREFCNT_inc (self); 158 SvREFCNT_inc (self);
159 hv_clear (self); 159 hv_clear (self);
160 sv_unmagic ((SV *)self, PERL_MAGIC_ext); 160 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
161 SvREFCNT_dec (self); 161 SvREFCNT_dec (self);
162 162
163 // self *must* be null now because thats sv_unmagic's job. 163 // self *must* be null now because that's sv_unmagic's job.
164 assert (!this->self); 164 assert (!this->self);
165 } 165 }
166} 166}
167 167
168void 168void
405 croak ("perl code used %s object, but C object is already destroyed, caught", klass); 405 croak ("perl code used %s object, but C object is already destroyed, caught", klass);
406 406
407 return (long)mg->mg_ptr; 407 return (long)mg->mg_ptr;
408} 408}
409 409
410static long 410static long noinline
411SvPTR_ornull (SV *sv, const char *klass) 411SvPTR_ornull (SV *sv, const char *klass)
412{ 412{
413 if (SvOK (sv)) 413 if (SvOK (sv))
414 return SvPTR (sv, klass); 414 return SvPTR (sv, klass);
415 else 415 else
607 va_end (ap); 607 va_end (ap);
608 608
609 return sv; 609 return sv;
610} 610}
611 611
612// typemap support, mostly to avoid excessive inlining
613template<class type>
614static void noinline
615cf_obj_to (SV *arg, type &var)
616{
617 sv_to (arg, var);
618 if (!var)
619 croak ("must not pass invalid/null cf_obj here");
620}
621
622template<class object>
623static void noinline
624cf_obj_ornull_to (SV *arg, object *&var)
625{
626 if (SvOK (arg))
627 {
628 sv_to (arg, var);
629 if (!var)
630 croak ("unable to convert perl object to C++ object");
631 }
632 else
633 var = 0;
634}
635
612////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 636//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
613 637
614SV * 638SV *
615registry (attachable *ext) 639registry (attachable *ext)
616{ 640{
660 printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); 684 printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV));
661 exit (EXIT_FAILURE); 685 exit (EXIT_FAILURE);
662 } 686 }
663} 687}
664 688
689void
665void cfperl_main () 690cfperl_main ()
666{ 691{
667 dSP; 692 dSP;
668 693
669 PUSHMARK (SP); 694 PUSHMARK (SP);
670 PUTBACK; 695 PUTBACK;
695# undef def 720# undef def
696}; 721};
697 722
698#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) 723#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE)
699 724
700static void 725static void noinline
701gather_callbacks (AV *&callbacks, AV *registry, event_type event) 726gather_callbacks (AV *&callbacks, AV *registry, event_type event)
702{ 727{
703 // event must be in array 728 // event must be in array
704 if (event >= 0 && event <= AvFILLp (registry)) 729 if (event >= 0 && event <= AvFILLp (registry))
705 { 730 {
791{ 816{
792 attachable::gather_callbacks (callbacks, event); 817 attachable::gather_callbacks (callbacks, event);
793 ::gather_callbacks (callbacks, cb_map, event); 818 ::gather_callbacks (callbacks, cb_map, event);
794} 819}
795 820
796void 821static void noinline
797_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) 822_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry)
798{ 823{
799 for (int event = 0; event <= AvFILLp (registry); ++event) 824 for (int event = 0; event <= AvFILLp (registry); ++event)
800 { 825 {
801 SV *cbs_ = AvARRAY (registry)[event]; 826 SV *cbs_ = AvARRAY (registry)[event];
811 } 836 }
812 } 837 }
813} 838}
814 839
815// very slow and inefficient way to recalculate the global want bitsets 840// very slow and inefficient way to recalculate the global want bitsets
816void 841static void
817_recalc_want () 842_recalc_want ()
818{ 843{
819 ev_want_event.reset (); 844 ev_want_event.reset ();
820 845
821 _recalc_want (ev_want_event, cb_global); 846 _recalc_want (ev_want_event, cb_global);
931} 956}
932 957
933///////////////////////////////////////////////////////////////////////////// 958/////////////////////////////////////////////////////////////////////////////
934// various c++ => perl glue functions 959// various c++ => perl glue functions
935 960
961void
936void cfperl_tick () 962cfperl_tick ()
937{ 963{
938 tick_pending = 1; 964 tick_pending = 1;
939 965
940 if (tick_inhibit) 966 if (tick_inhibit)
941 return; 967 return;
1078 CALL_CALL ("cf::map::do_load_sync", G_SCALAR); 1104 CALL_CALL ("cf::map::do_load_sync", G_SCALAR);
1079 CALL_END; 1105 CALL_END;
1080} 1106}
1081 1107
1082void 1108void
1083maptile::change_all_map_light (int change)
1084{
1085 CALL_BEGIN (1);
1086 CALL_ARG (change);
1087 CALL_CALL ("cf::map::change_all_map_light", G_VOID);
1088 CALL_END;
1089}
1090
1091void
1092object::enter_exit (object *exit) 1109object::enter_exit (object *exit)
1093{ 1110{
1094 if (type != PLAYER) 1111 if (type != PLAYER)
1095 return; 1112 return;
1096 1113
1164///////////////////////////////////////////////////////////////////////////// 1181/////////////////////////////////////////////////////////////////////////////
1165 1182
1166struct EVAPI *evapi::GEVAPI; 1183struct EVAPI *evapi::GEVAPI;
1167struct CoroAPI *coroapi::GCoroAPI; 1184struct CoroAPI *coroapi::GCoroAPI;
1168 1185
1186void
1169void coroapi::do_cede_to_tick () 1187coroapi::do_cede_to_tick ()
1170{ 1188{
1171 cede_pending = 0; 1189 cede_pending = 0;
1172 cede (); 1190 cede ();
1173} 1191}
1174 1192
1198 ev_io_set ((ev_io *)this, fd, events); 1216 ev_io_set ((ev_io *)this, fd, events);
1199 if (active) start (); 1217 if (active) start ();
1200 } 1218 }
1201} 1219}
1202 1220
1203void 1221static void
1204_connect_to_perl () 1222_connect_to_perl ()
1205{ 1223{
1206 stash_cf = gv_stashpv ("cf", 1); 1224 stash_cf = gv_stashpv ("cf", 1);
1207 1225
1208 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1226 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1339 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) 1357 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED)
1340 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) 1358 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON)
1341 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) 1359 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON)
1342 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK) 1360 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK)
1343 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) 1361 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL)
1344 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) 1362 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) const_iv (FLAG_WIZLOOK)
1345 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) 1363 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE)
1346 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) 1364 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE)
1347 1365
1348 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) 1366 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED)
1349 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) 1367 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN)
1600 1618
1601void init_attackmess () 1619void init_attackmess ()
1602 1620
1603void init_dynamic () 1621void init_dynamic ()
1604 1622
1605void init_block ()
1606
1607void load_settings () 1623void load_settings ()
1608 1624
1609void load_materials () 1625void load_materials ()
1610 1626
1611void init_uuid () 1627void init_uuid ()
2250 pl->ob->stats.hp = pl->ob->stats.maxhp; 2266 pl->ob->stats.hp = pl->ob->stats.maxhp;
2251 pl->ob->stats.sp = pl->ob->stats.maxsp; 2267 pl->ob->stats.sp = pl->ob->stats.maxsp;
2252 pl->ob->stats.grace = pl->ob->stats.maxgrace; 2268 pl->ob->stats.grace = pl->ob->stats.maxgrace;
2253 pl->orig_stats = pl->ob->stats; 2269 pl->orig_stats = pl->ob->stats;
2254 2270
2255void clear_los (player *pl)
2256
2257# should only be temporary 2271# should only be temporary
2258void esrv_new_player (player *pl) 2272void esrv_new_player (player *pl)
2259 2273
2274#d# TODO: replace by blocked_los accessor, fix code using this
2260bool 2275bool
2261cell_visible (player *pl, int dx, int dy) 2276cell_visible (player *pl, int dx, int dy)
2262 CODE: 2277 CODE:
2263 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 2278 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED;
2264 && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2];
2265 OUTPUT: 2279 OUTPUT:
2266 RETVAL 2280 RETVAL
2267 2281
2268void 2282void
2269send (player *pl, SV *packet) 2283send (player *pl, SV *packet)
2335 XPUSHs (sv_2mortal (to_sv (op))); 2349 XPUSHs (sv_2mortal (to_sv (op)));
2336 } 2350 }
2337} 2351}
2338 2352
2339INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | 2353INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h |
2354
2355void
2356adjust_daylight ()
2357 CODE:
2358 maptile::adjust_daylight ();
2340 2359
2341void 2360void
2342maptile::instantiate () 2361maptile::instantiate ()
2343 2362
2344maptile *new () 2363maptile *new ()
2701 PROTOTYPE: $ 2720 PROTOTYPE: $
2702 CODE: 2721 CODE:
2703 RETVAL = region::find (name); 2722 RETVAL = region::find (name);
2704 OUTPUT: RETVAL 2723 OUTPUT: RETVAL
2705 2724
2706region *find_fuzzy (utf8_string name)
2707 PROTOTYPE: $
2708 CODE:
2709 RETVAL = region::find_fuzzy (name);
2710 OUTPUT: RETVAL
2711
2712int specificity (region *rgn) 2725int specificity (region *rgn)
2713 CODE: 2726 CODE:
2714 RETVAL = 0; 2727 RETVAL = 0;
2715 while (rgn = rgn->parent) 2728 while (rgn = rgn->parent)
2716 RETVAL++; 2729 RETVAL++;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines