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.143 by root, Fri Jan 19 15:29:52 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)
1549 1552
1550NV floor (NV x) 1553NV floor (NV x)
1551 1554
1552NV ceil (NV x) 1555NV ceil (NV x)
1553 1556
1557NV rndm (...)
1558 CODE:
1559 switch (items)
1560 {
1561 case 0: RETVAL = rndm (); break;
1562 case 1: RETVAL = rndm (SvUV (ST (0))); break;
1563 case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break;
1564 default: croak ("cf::rndm requires none, one or two parameters."); break;
1565 }
1566 OUTPUT:
1567 RETVAL
1568
1554void server_tick () 1569void server_tick ()
1555 CODE: 1570 CODE:
1556 runtime = SvNVx (sv_runtime); 1571 runtime = SvNVx (sv_runtime);
1557 server_tick (); 1572 server_tick ();
1558 1573
1837 1852
1838void drop (object *who, object *op) 1853void drop (object *who, object *op)
1839 1854
1840void pick_up (object *who, object *op) 1855void pick_up (object *who, object *op)
1841 1856
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) 1857int cf_object_teleport (object *op, maptile *map, int x, int y)
1847 1858
1848void update_object (object *op, int action) 1859void update_object (object *op, int action)
1849 1860
1850object *cf_create_object_by_name (const char *name) 1861object *cf_create_object_by_name (const char *name)
1968 1979
1969void esrv_update_item (object *op, int what, object *item) 1980void esrv_update_item (object *op, int what, object *item)
1970 C_ARGS: what, op, item 1981 C_ARGS: what, op, item
1971 1982
1972void clear_los (object *op) 1983void clear_los (object *op)
1973
1974int command_teleport (object *op, char *params)
1975 1984
1976int command_summon (object *op, char *params) 1985int command_summon (object *op, char *params)
1977 1986
1978int command_arrest (object *op, char *params) 1987int command_arrest (object *op, char *params)
1979 1988
2122 2131
2123object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) 2132object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2124 C_ARGS: str, map, nx, ny 2133 C_ARGS: str, map, nx, ny
2125 2134
2126void 2135void
2127cf_map_normalise (maptile *map, int x, int y) 2136get_map_flags (maptile *map, int x, int y)
2128 PPCODE: 2137 PPCODE:
2129{ 2138{
2130 maptile *nmap = 0; 2139 maptile *nmap = 0;
2131 I16 nx = 0, ny = 0; 2140 I16 nx = 0, ny = 0;
2132 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2141 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2194 CODE: 2203 CODE:
2195 RETVAL = get_name_of_region_for_map (m); 2204 RETVAL = get_name_of_region_for_map (m);
2196 OUTPUT: RETVAL 2205 OUTPUT: RETVAL
2197 2206
2198# worst xs function of my life 2207# worst xs function of my life
2199maptile * 2208bool
2200_create_random_map (\ 2209_create_random_map (\
2201 char *path,\ 2210 maptile *self,\
2202 char *wallstyle,\ 2211 char *wallstyle,\
2203 char *wall_name,\ 2212 char *wall_name,\
2204 char *floorstyle,\ 2213 char *floorstyle,\
2205 char *monsterstyle,\ 2214 char *monsterstyle,\
2206 char *treasurestyle,\ 2215 char *treasurestyle,\
2231 int random_seed,\ 2240 int random_seed,\
2232 val64 total_map_hp,\ 2241 val64 total_map_hp,\
2233 int map_layout_style,\ 2242 int map_layout_style,\
2234 int treasureoptions,\ 2243 int treasureoptions,\
2235 int symmetry_used,\ 2244 int symmetry_used,\
2236 region *region\ 2245 region *region,\
2246 char *custom\
2237) 2247)
2238 CODE: 2248 CODE:
2239{ 2249{
2240 random_map_params rmp; 2250 random_map_params rmp;
2241 2251
2273 rmp.total_map_hp = total_map_hp; 2283 rmp.total_map_hp = total_map_hp;
2274 rmp.map_layout_style = map_layout_style; 2284 rmp.map_layout_style = map_layout_style;
2275 rmp.treasureoptions = treasureoptions; 2285 rmp.treasureoptions = treasureoptions;
2276 rmp.symmetry_used = symmetry_used; 2286 rmp.symmetry_used = symmetry_used;
2277 rmp.region = region; 2287 rmp.region = region;
2288 rmp.custom = custom;
2278 2289
2279 RETVAL = generate_random_map (path, &rmp); 2290 RETVAL = self->generate_random_map (&rmp);
2280} 2291}
2281 OUTPUT: 2292 OUTPUT:
2282 RETVAL 2293 RETVAL
2283 2294
2284MODULE = cf PACKAGE = cf::arch 2295MODULE = cf PACKAGE = cf::arch

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines