… | |
… | |
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 | |
251 | static void |
258 | static void |
252 | clearSVptr (SV *sv) |
259 | clearSVptr (SV *sv) |
253 | { |
260 | { |
… | |
… | |
306 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
313 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
307 | |
314 | |
308 | inline SV *to_sv (object & v) { return to_sv (&v); } |
315 | inline SV *to_sv (object & v) { return to_sv (&v); } |
309 | inline SV *to_sv (living & v) { return to_sv (&v); } |
316 | inline SV *to_sv (living & v) { return to_sv (&v); } |
310 | |
317 | |
311 | //TODO: |
|
|
312 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
318 | inline SV *to_sv (facetile * v) { return to_sv (v->name); } |
313 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
319 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
314 | |
320 | |
315 | inline SV *to_sv (UUID v) |
321 | inline SV *to_sv (UUID v) |
316 | { |
322 | { |
317 | char buf[128]; |
323 | char buf[128]; |
… | |
… | |
342 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
348 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
343 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
349 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
344 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
350 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
345 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
351 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
346 | |
352 | |
347 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
353 | inline void sv_to (SV *sv, facetile * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } |
348 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
354 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } |
349 | |
355 | |
350 | template<class T> |
356 | template<class T> |
351 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
357 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
352 | |
358 | |
353 | template<int N> |
359 | template<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 |
|
|
496 | void 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 | |
522 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) |
503 | extern "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 | |
|
|
831 | maptile * |
|
|
832 | maptile::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) |
… | |
… | |
1549 | |
1552 | |
1550 | NV floor (NV x) |
1553 | NV floor (NV x) |
1551 | |
1554 | |
1552 | NV ceil (NV x) |
1555 | NV ceil (NV x) |
1553 | |
1556 | |
|
|
1557 | NV 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 | |
1554 | void server_tick () |
1569 | void server_tick () |
1555 | CODE: |
1570 | CODE: |
1556 | runtime = SvNVx (sv_runtime); |
1571 | runtime = SvNVx (sv_runtime); |
1557 | server_tick (); |
1572 | server_tick (); |
1558 | |
1573 | |
… | |
… | |
1604 | } |
1619 | } |
1605 | OUTPUT: RETVAL |
1620 | OUTPUT: RETVAL |
1606 | |
1621 | |
1607 | void abort () |
1622 | void abort () |
1608 | |
1623 | |
|
|
1624 | void fork_abort (char *cause = "cf::fork_abort") |
|
|
1625 | |
1609 | void cleanup (const char *cause, bool make_core = false) |
1626 | void cleanup (const char *cause, bool make_core = false) |
1610 | |
1627 | |
1611 | void emergency_save () |
1628 | void emergency_save () |
1612 | |
1629 | |
1613 | void _exit (int status = 0) |
1630 | void _exit (int status = 0) |
… | |
… | |
1837 | |
1854 | |
1838 | void drop (object *who, object *op) |
1855 | void drop (object *who, object *op) |
1839 | |
1856 | |
1840 | void pick_up (object *who, object *op) |
1857 | void pick_up (object *who, object *op) |
1841 | |
1858 | |
1842 | object *cf_object_insert_object (object *op, object *container) |
|
|
1843 | |
|
|
1844 | object *cf_object_insert_in_ob (object *ob, object *where) |
|
|
1845 | |
|
|
1846 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1859 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1847 | |
1860 | |
1848 | void update_object (object *op, int action) |
1861 | void update_object (object *op, int action) |
1849 | |
1862 | |
1850 | object *cf_create_object_by_name (const char *name) |
1863 | object *cf_create_object_by_name (const char *name) |
… | |
… | |
1968 | |
1981 | |
1969 | void esrv_update_item (object *op, int what, object *item) |
1982 | void esrv_update_item (object *op, int what, object *item) |
1970 | C_ARGS: what, op, item |
1983 | C_ARGS: what, op, item |
1971 | |
1984 | |
1972 | void clear_los (object *op) |
1985 | void clear_los (object *op) |
1973 | |
|
|
1974 | int command_teleport (object *op, char *params) |
|
|
1975 | |
1986 | |
1976 | int command_summon (object *op, char *params) |
1987 | int command_summon (object *op, char *params) |
1977 | |
1988 | |
1978 | int command_arrest (object *op, char *params) |
1989 | int command_arrest (object *op, char *params) |
1979 | |
1990 | |
… | |
… | |
2122 | |
2133 | |
2123 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2134 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2124 | C_ARGS: str, map, nx, ny |
2135 | C_ARGS: str, map, nx, ny |
2125 | |
2136 | |
2126 | void |
2137 | void |
2127 | cf_map_normalise (maptile *map, int x, int y) |
2138 | get_map_flags (maptile *map, int x, int y) |
2128 | PPCODE: |
2139 | PPCODE: |
2129 | { |
2140 | { |
2130 | maptile *nmap = 0; |
2141 | maptile *nmap = 0; |
2131 | I16 nx = 0, ny = 0; |
2142 | I16 nx = 0, ny = 0; |
2132 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2143 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
… | |
… | |
2194 | CODE: |
2205 | CODE: |
2195 | RETVAL = get_name_of_region_for_map (m); |
2206 | RETVAL = get_name_of_region_for_map (m); |
2196 | OUTPUT: RETVAL |
2207 | OUTPUT: RETVAL |
2197 | |
2208 | |
2198 | # worst xs function of my life |
2209 | # worst xs function of my life |
2199 | maptile * |
2210 | bool |
2200 | _create_random_map (\ |
2211 | _create_random_map (\ |
2201 | char *path,\ |
2212 | maptile *self,\ |
2202 | char *wallstyle,\ |
2213 | char *wallstyle,\ |
2203 | char *wall_name,\ |
2214 | char *wall_name,\ |
2204 | char *floorstyle,\ |
2215 | char *floorstyle,\ |
2205 | char *monsterstyle,\ |
2216 | char *monsterstyle,\ |
2206 | char *treasurestyle,\ |
2217 | char *treasurestyle,\ |
… | |
… | |
2210 | char *origin_map,\ |
2221 | char *origin_map,\ |
2211 | char *final_map,\ |
2222 | char *final_map,\ |
2212 | char *exitstyle,\ |
2223 | char *exitstyle,\ |
2213 | char *this_map,\ |
2224 | char *this_map,\ |
2214 | char *exit_on_final_map,\ |
2225 | char *exit_on_final_map,\ |
2215 | int Xsize,\ |
2226 | int xsize,\ |
2216 | int Ysize,\ |
2227 | int ysize,\ |
2217 | int expand2x,\ |
2228 | int expand2x,\ |
2218 | int layoutoptions1,\ |
2229 | int layoutoptions1,\ |
2219 | int layoutoptions2,\ |
2230 | int layoutoptions2,\ |
2220 | int layoutoptions3,\ |
2231 | int layoutoptions3,\ |
2221 | int symmetry,\ |
2232 | int symmetry,\ |
… | |
… | |
2226 | int dungeon_depth,\ |
2237 | int dungeon_depth,\ |
2227 | int decoroptions,\ |
2238 | int decoroptions,\ |
2228 | int orientation,\ |
2239 | int orientation,\ |
2229 | int origin_y,\ |
2240 | int origin_y,\ |
2230 | int origin_x,\ |
2241 | int origin_x,\ |
2231 | int random_seed,\ |
2242 | U32 random_seed,\ |
2232 | val64 total_map_hp,\ |
2243 | val64 total_map_hp,\ |
2233 | int map_layout_style,\ |
2244 | int map_layout_style,\ |
2234 | int treasureoptions,\ |
2245 | int treasureoptions,\ |
2235 | int symmetry_used,\ |
2246 | int symmetry_used,\ |
2236 | region *region\ |
2247 | region *region,\ |
|
|
2248 | char *custom\ |
2237 | ) |
2249 | ) |
2238 | CODE: |
2250 | CODE: |
2239 | { |
2251 | { |
2240 | random_map_params rmp; |
2252 | random_map_params rmp; |
2241 | |
2253 | |
… | |
… | |
2251 | assign (rmp.exit_on_final_map, exit_on_final_map); |
2263 | assign (rmp.exit_on_final_map, exit_on_final_map); |
2252 | |
2264 | |
2253 | rmp.origin_map = origin_map; |
2265 | rmp.origin_map = origin_map; |
2254 | rmp.final_map = final_map; |
2266 | rmp.final_map = final_map; |
2255 | rmp.this_map = this_map; |
2267 | rmp.this_map = this_map; |
2256 | rmp.Xsize = Xsize; |
2268 | rmp.xsize = xsize; |
2257 | rmp.Ysize = Ysize; |
2269 | rmp.ysize = ysize; |
2258 | rmp.expand2x = expand2x; |
2270 | rmp.expand2x = expand2x; |
2259 | rmp.layoutoptions1 = layoutoptions1; |
2271 | rmp.layoutoptions1 = layoutoptions1; |
2260 | rmp.layoutoptions2 = layoutoptions2; |
2272 | rmp.layoutoptions2 = layoutoptions2; |
2261 | rmp.layoutoptions3 = layoutoptions3; |
2273 | rmp.layoutoptions3 = layoutoptions3; |
2262 | rmp.symmetry = symmetry; |
2274 | rmp.symmetry = symmetry; |
… | |
… | |
2273 | rmp.total_map_hp = total_map_hp; |
2285 | rmp.total_map_hp = total_map_hp; |
2274 | rmp.map_layout_style = map_layout_style; |
2286 | rmp.map_layout_style = map_layout_style; |
2275 | rmp.treasureoptions = treasureoptions; |
2287 | rmp.treasureoptions = treasureoptions; |
2276 | rmp.symmetry_used = symmetry_used; |
2288 | rmp.symmetry_used = symmetry_used; |
2277 | rmp.region = region; |
2289 | rmp.region = region; |
|
|
2290 | rmp.custom = custom; |
2278 | |
2291 | |
2279 | RETVAL = generate_random_map (path, &rmp); |
2292 | RETVAL = self->generate_random_map (&rmp); |
2280 | } |
2293 | } |
2281 | OUTPUT: |
2294 | OUTPUT: |
2282 | RETVAL |
2295 | RETVAL |
2283 | |
2296 | |
2284 | MODULE = cf PACKAGE = cf::arch |
2297 | MODULE = cf PACKAGE = cf::arch |