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.134 by root, Tue Jan 9 21:32:42 2007 UTC vs.
Revision 1.142 by elmex, Sun Jan 14 11:00:47 2007 UTC

243 243
244 // now bless the object _once_ 244 // now bless the object _once_
245 return sv_bless (newRV_inc ((SV *)obj->self), stash); 245 return sv_bless (newRV_inc ((SV *)obj->self), stash);
246 } 246 }
247 else 247 else
248 {
248 return newRV_inc ((SV *)obj->self); 249 SV *sv = newRV_inc ((SV *)obj->self);
250
251 if (Gv_AMG (stash)) // handle overload correctly, as the perl core does not
252 SvAMAGIC_on (sv);
253
254 return sv;
255 }
249} 256}
250 257
251static void 258static void
252clearSVptr (SV *sv) 259clearSVptr (SV *sv)
253{ 260{
306inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 313inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
307 314
308inline SV *to_sv (object & v) { return to_sv (&v); } 315inline SV *to_sv (object & v) { return to_sv (&v); }
309inline SV *to_sv (living & v) { return to_sv (&v); } 316inline SV *to_sv (living & v) { return to_sv (&v); }
310 317
311//TODO:
312inline SV *to_sv (New_Face * v) { return to_sv (v->name); } 318inline SV *to_sv (New_Face * v) { return to_sv (v->name); }
313inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } 319inline SV *to_sv (treasurelist * v) { return to_sv (v->name); }
314 320
315inline SV *to_sv (UUID v) 321inline SV *to_sv (UUID v)
316{ 322{
342inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 348inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
343inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 349inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
344inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } 350inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); }
345inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 351inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
346 352
347inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO 353inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; }
348inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO 354inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); }
349 355
350template<class T> 356template<class T>
351inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 357inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
352 358
353template<int N> 359template<int N>
489 if (!ext->cb) 495 if (!ext->cb)
490 ext->cb = newAV (); 496 ext->cb = newAV ();
491 497
492 return newRV_inc ((SV *)ext->cb); 498 return newRV_inc ((SV *)ext->cb);
493} 499}
494
495#if 0
496void attachable::clear ()
497{
498 if (self)
499 {
500 // disconnect Perl from C, to avoid crashes
501 sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext);
502
503 // clear the perl hash, might or might not be a good idea
504 hv_clear ((HV *)SvRV ((SV *)self));
505
506 SvREFCNT_dec (self);
507 self = 0;
508 }
509
510 if (cb)
511 {
512 SvREFCNT_dec (cb);
513 cb = 0;
514 }
515
516 attach = 0;
517}
518#endif
519 500
520///////////////////////////////////////////////////////////////////////////// 501/////////////////////////////////////////////////////////////////////////////
521 502
522extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) 503extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr)
523{ 504{
832{ 813{
833 CALL_BEGIN (2); 814 CALL_BEGIN (2);
834 CALL_ARG (path); 815 CALL_ARG (path);
835 CALL_ARG (origin); 816 CALL_ARG (origin);
836 CALL_CALL ("cf::map::find_sync", G_SCALAR); 817 CALL_CALL ("cf::map::find_sync", G_SCALAR);
818
819 maptile *retval;
820
821 if (count)
822 sv_to (POPs, retval);
823 else
824 retval = 0;
825
826 CALL_END;
827
828 return retval;
829}
830
831maptile *
832maptile::find_async (const char *path, maptile *origin)
833{
834 CALL_BEGIN (2);
835 CALL_ARG (path);
836 CALL_ARG (origin);
837 CALL_CALL ("cf::map::find_async", G_SCALAR);
837 838
838 maptile *retval; 839 maptile *retval;
839 840
840 if (count) 841 if (count)
841 sv_to (POPs, retval); 842 sv_to (POPs, retval);
1246 const_iv (FLAG_ACTIVATE_ON_RELEASE) 1247 const_iv (FLAG_ACTIVATE_ON_RELEASE)
1247 const_iv (FLAG_IS_WATER) 1248 const_iv (FLAG_IS_WATER)
1248 const_iv (FLAG_CONTENT_ON_GEN) 1249 const_iv (FLAG_CONTENT_ON_GEN)
1249 const_iv (FLAG_IS_A_TEMPLATE) 1250 const_iv (FLAG_IS_A_TEMPLATE)
1250 const_iv (FLAG_IS_BUILDABLE) 1251 const_iv (FLAG_IS_BUILDABLE)
1252 const_iv (FLAG_DESTROY_ON_DEATH)
1253 const_iv (FLAG_NO_SAVE)
1251 1254
1252 const_iv (NDI_BLACK) 1255 const_iv (NDI_BLACK)
1253 const_iv (NDI_WHITE) 1256 const_iv (NDI_WHITE)
1254 const_iv (NDI_NAVY) 1257 const_iv (NDI_NAVY)
1255 const_iv (NDI_RED) 1258 const_iv (NDI_RED)
1837 1840
1838void drop (object *who, object *op) 1841void drop (object *who, object *op)
1839 1842
1840void pick_up (object *who, object *op) 1843void pick_up (object *who, object *op)
1841 1844
1842object *cf_object_insert_object (object *op, object *container)
1843
1844object *cf_object_insert_in_ob (object *ob, object *where)
1845
1846int cf_object_teleport (object *op, maptile *map, int x, int y) 1845int cf_object_teleport (object *op, maptile *map, int x, int y)
1847 1846
1848void update_object (object *op, int action) 1847void update_object (object *op, int action)
1849 1848
1850object *cf_create_object_by_name (const char *name) 1849object *cf_create_object_by_name (const char *name)
1968 1967
1969void esrv_update_item (object *op, int what, object *item) 1968void esrv_update_item (object *op, int what, object *item)
1970 C_ARGS: what, op, item 1969 C_ARGS: what, op, item
1971 1970
1972void clear_los (object *op) 1971void clear_los (object *op)
1973
1974int command_teleport (object *op, char *params)
1975 1972
1976int command_summon (object *op, char *params) 1973int command_summon (object *op, char *params)
1977 1974
1978int command_arrest (object *op, char *params) 1975int command_arrest (object *op, char *params)
1979 1976
2122 2119
2123object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) 2120object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2124 C_ARGS: str, map, nx, ny 2121 C_ARGS: str, map, nx, ny
2125 2122
2126void 2123void
2127cf_map_normalise (maptile *map, int x, int y) 2124get_map_flags (maptile *map, int x, int y)
2128 PPCODE: 2125 PPCODE:
2129{ 2126{
2130 maptile *nmap = 0; 2127 maptile *nmap = 0;
2131 I16 nx = 0, ny = 0; 2128 I16 nx = 0, ny = 0;
2132 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2129 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2194 CODE: 2191 CODE:
2195 RETVAL = get_name_of_region_for_map (m); 2192 RETVAL = get_name_of_region_for_map (m);
2196 OUTPUT: RETVAL 2193 OUTPUT: RETVAL
2197 2194
2198# worst xs function of my life 2195# worst xs function of my life
2199maptile * 2196bool
2200_create_random_map (\ 2197_create_random_map (\
2201 char *path,\ 2198 maptile *self,\
2202 char *wallstyle,\ 2199 char *wallstyle,\
2203 char *wall_name,\ 2200 char *wall_name,\
2204 char *floorstyle,\ 2201 char *floorstyle,\
2205 char *monsterstyle,\ 2202 char *monsterstyle,\
2206 char *treasurestyle,\ 2203 char *treasurestyle,\
2231 int random_seed,\ 2228 int random_seed,\
2232 val64 total_map_hp,\ 2229 val64 total_map_hp,\
2233 int map_layout_style,\ 2230 int map_layout_style,\
2234 int treasureoptions,\ 2231 int treasureoptions,\
2235 int symmetry_used,\ 2232 int symmetry_used,\
2236 region *region\ 2233 region *region,\
2234 char *custom\
2237) 2235)
2238 CODE: 2236 CODE:
2239{ 2237{
2240 random_map_params rmp; 2238 random_map_params rmp;
2241 2239
2273 rmp.total_map_hp = total_map_hp; 2271 rmp.total_map_hp = total_map_hp;
2274 rmp.map_layout_style = map_layout_style; 2272 rmp.map_layout_style = map_layout_style;
2275 rmp.treasureoptions = treasureoptions; 2273 rmp.treasureoptions = treasureoptions;
2276 rmp.symmetry_used = symmetry_used; 2274 rmp.symmetry_used = symmetry_used;
2277 rmp.region = region; 2275 rmp.region = region;
2276 rmp.custom = custom;
2278 2277
2279 RETVAL = generate_random_map (path, &rmp); 2278 RETVAL = self->generate_random_map (&rmp);
2280} 2279}
2281 OUTPUT: 2280 OUTPUT:
2282 RETVAL 2281 RETVAL
2283 2282
2284MODULE = cf PACKAGE = cf::arch 2283MODULE = cf PACKAGE = cf::arch

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines