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.148 by root, Sat Jan 20 23:39:09 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 (facetile * 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{
317 char buf[128]; 323 char buf[128];
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, facetile * &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_MAP_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)
1440 const_iv (ATNR_BLIND) 1443 const_iv (ATNR_BLIND)
1441 const_iv (ATNR_INTERNAL) 1444 const_iv (ATNR_INTERNAL)
1442 const_iv (ATNR_LIFE_STEALING) 1445 const_iv (ATNR_LIFE_STEALING)
1443 const_iv (ATNR_DISEASE) 1446 const_iv (ATNR_DISEASE)
1444 1447
1445 const_iv (MAP_FLUSH)
1446 const_iv (MAP_PLAYER_UNIQUE)
1447 const_iv (MAP_BLOCK)
1448 const_iv (MAP_STYLE)
1449 const_iv (MAP_OVERLAY)
1450
1451 const_iv (MAP_IN_MEMORY) 1448 const_iv (MAP_IN_MEMORY)
1452 const_iv (MAP_SWAPPED) 1449 const_iv (MAP_SWAPPED)
1453 const_iv (MAP_LOADING) 1450 const_iv (MAP_LOADING)
1454 const_iv (MAP_SAVING) 1451 const_iv (MAP_SAVING)
1455 1452
1548} 1545}
1549 1546
1550NV floor (NV x) 1547NV floor (NV x)
1551 1548
1552NV ceil (NV x) 1549NV ceil (NV x)
1550
1551NV rndm (...)
1552 CODE:
1553 switch (items)
1554 {
1555 case 0: RETVAL = rndm (); break;
1556 case 1: RETVAL = rndm (SvUV (ST (0))); break;
1557 case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break;
1558 default: croak ("cf::rndm requires none, one or two parameters."); break;
1559 }
1560 OUTPUT:
1561 RETVAL
1553 1562
1554void server_tick () 1563void server_tick ()
1555 CODE: 1564 CODE:
1556 runtime = SvNVx (sv_runtime); 1565 runtime = SvNVx (sv_runtime);
1557 server_tick (); 1566 server_tick ();
1604 } 1613 }
1605 OUTPUT: RETVAL 1614 OUTPUT: RETVAL
1606 1615
1607void abort () 1616void abort ()
1608 1617
1618void fork_abort (char *cause = "cf::fork_abort")
1619
1609void cleanup (const char *cause, bool make_core = false) 1620void cleanup (const char *cause, bool make_core = false)
1610 1621
1611void emergency_save () 1622void emergency_save ()
1612 1623
1613void _exit (int status = 0) 1624void _exit (int status = 0)
1837 1848
1838void drop (object *who, object *op) 1849void drop (object *who, object *op)
1839 1850
1840void pick_up (object *who, object *op) 1851void pick_up (object *who, object *op)
1841 1852
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) 1853int cf_object_teleport (object *op, maptile *map, int x, int y)
1847 1854
1848void update_object (object *op, int action) 1855void update_object (object *op, int action)
1849 1856
1850object *cf_create_object_by_name (const char *name) 1857object *cf_create_object_by_name (const char *name)
1968 1975
1969void esrv_update_item (object *op, int what, object *item) 1976void esrv_update_item (object *op, int what, object *item)
1970 C_ARGS: what, op, item 1977 C_ARGS: what, op, item
1971 1978
1972void clear_los (object *op) 1979void clear_los (object *op)
1973
1974int command_teleport (object *op, char *params)
1975 1980
1976int command_summon (object *op, char *params) 1981int command_summon (object *op, char *params)
1977 1982
1978int command_arrest (object *op, char *params) 1983int command_arrest (object *op, char *params)
1979 1984
2122 2127
2123object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) 2128object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny)
2124 C_ARGS: str, map, nx, ny 2129 C_ARGS: str, map, nx, ny
2125 2130
2126void 2131void
2127cf_map_normalise (maptile *map, int x, int y) 2132get_map_flags (maptile *map, int x, int y)
2128 PPCODE: 2133 PPCODE:
2129{ 2134{
2130 maptile *nmap = 0; 2135 maptile *nmap = 0;
2131 I16 nx = 0, ny = 0; 2136 I16 nx = 0, ny = 0;
2132 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2137 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2194 CODE: 2199 CODE:
2195 RETVAL = get_name_of_region_for_map (m); 2200 RETVAL = get_name_of_region_for_map (m);
2196 OUTPUT: RETVAL 2201 OUTPUT: RETVAL
2197 2202
2198# worst xs function of my life 2203# worst xs function of my life
2199maptile * 2204bool
2200_create_random_map (\ 2205_create_random_map (\
2201 char *path,\ 2206 maptile *self,\
2202 char *wallstyle,\ 2207 char *wallstyle,\
2203 char *wall_name,\ 2208 char *wall_name,\
2204 char *floorstyle,\ 2209 char *floorstyle,\
2205 char *monsterstyle,\ 2210 char *monsterstyle,\
2206 char *treasurestyle,\ 2211 char *treasurestyle,\
2210 char *origin_map,\ 2215 char *origin_map,\
2211 char *final_map,\ 2216 char *final_map,\
2212 char *exitstyle,\ 2217 char *exitstyle,\
2213 char *this_map,\ 2218 char *this_map,\
2214 char *exit_on_final_map,\ 2219 char *exit_on_final_map,\
2215 int Xsize,\ 2220 int xsize,\
2216 int Ysize,\ 2221 int ysize,\
2217 int expand2x,\ 2222 int expand2x,\
2218 int layoutoptions1,\ 2223 int layoutoptions1,\
2219 int layoutoptions2,\ 2224 int layoutoptions2,\
2220 int layoutoptions3,\ 2225 int layoutoptions3,\
2221 int symmetry,\ 2226 int symmetry,\
2226 int dungeon_depth,\ 2231 int dungeon_depth,\
2227 int decoroptions,\ 2232 int decoroptions,\
2228 int orientation,\ 2233 int orientation,\
2229 int origin_y,\ 2234 int origin_y,\
2230 int origin_x,\ 2235 int origin_x,\
2231 int random_seed,\ 2236 U32 random_seed,\
2232 val64 total_map_hp,\ 2237 val64 total_map_hp,\
2233 int map_layout_style,\ 2238 int map_layout_style,\
2234 int treasureoptions,\ 2239 int treasureoptions,\
2235 int symmetry_used,\ 2240 int symmetry_used,\
2236 region *region\ 2241 region *region,\
2242 char *custom\
2237) 2243)
2238 CODE: 2244 CODE:
2239{ 2245{
2240 random_map_params rmp; 2246 random_map_params rmp;
2241 2247
2251 assign (rmp.exit_on_final_map, exit_on_final_map); 2257 assign (rmp.exit_on_final_map, exit_on_final_map);
2252 2258
2253 rmp.origin_map = origin_map; 2259 rmp.origin_map = origin_map;
2254 rmp.final_map = final_map; 2260 rmp.final_map = final_map;
2255 rmp.this_map = this_map; 2261 rmp.this_map = this_map;
2256 rmp.Xsize = Xsize; 2262 rmp.xsize = xsize;
2257 rmp.Ysize = Ysize; 2263 rmp.ysize = ysize;
2258 rmp.expand2x = expand2x; 2264 rmp.expand2x = expand2x;
2259 rmp.layoutoptions1 = layoutoptions1; 2265 rmp.layoutoptions1 = layoutoptions1;
2260 rmp.layoutoptions2 = layoutoptions2; 2266 rmp.layoutoptions2 = layoutoptions2;
2261 rmp.layoutoptions3 = layoutoptions3; 2267 rmp.layoutoptions3 = layoutoptions3;
2262 rmp.symmetry = symmetry; 2268 rmp.symmetry = symmetry;
2273 rmp.total_map_hp = total_map_hp; 2279 rmp.total_map_hp = total_map_hp;
2274 rmp.map_layout_style = map_layout_style; 2280 rmp.map_layout_style = map_layout_style;
2275 rmp.treasureoptions = treasureoptions; 2281 rmp.treasureoptions = treasureoptions;
2276 rmp.symmetry_used = symmetry_used; 2282 rmp.symmetry_used = symmetry_used;
2277 rmp.region = region; 2283 rmp.region = region;
2284 rmp.custom = custom;
2278 2285
2279 RETVAL = generate_random_map (path, &rmp); 2286 RETVAL = self->generate_random_map (&rmp);
2280} 2287}
2281 OUTPUT: 2288 OUTPUT:
2282 RETVAL 2289 RETVAL
2283 2290
2284MODULE = cf PACKAGE = cf::arch 2291MODULE = cf PACKAGE = cf::arch

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines