… | |
… | |
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 (New_Face * 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 | { |
… | |
… | |
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, New_Face * &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_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 | |
1838 | void drop (object *who, object *op) |
1841 | void drop (object *who, object *op) |
1839 | |
1842 | |
1840 | void pick_up (object *who, object *op) |
1843 | void pick_up (object *who, object *op) |
1841 | |
1844 | |
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) |
1845 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1847 | |
1846 | |
1848 | void update_object (object *op, int action) |
1847 | void update_object (object *op, int action) |
1849 | |
1848 | |
1850 | object *cf_create_object_by_name (const char *name) |
1849 | object *cf_create_object_by_name (const char *name) |
… | |
… | |
1968 | |
1967 | |
1969 | void esrv_update_item (object *op, int what, object *item) |
1968 | void esrv_update_item (object *op, int what, object *item) |
1970 | C_ARGS: what, op, item |
1969 | C_ARGS: what, op, item |
1971 | |
1970 | |
1972 | void clear_los (object *op) |
1971 | void clear_los (object *op) |
1973 | |
|
|
1974 | int command_teleport (object *op, char *params) |
|
|
1975 | |
1972 | |
1976 | int command_summon (object *op, char *params) |
1973 | int command_summon (object *op, char *params) |
1977 | |
1974 | |
1978 | int command_arrest (object *op, char *params) |
1975 | int command_arrest (object *op, char *params) |
1979 | |
1976 | |
… | |
… | |
2122 | |
2119 | |
2123 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2120 | object* 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 | |
2126 | void |
2123 | void |
2127 | cf_map_normalise (maptile *map, int x, int y) |
2124 | get_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 |
2199 | maptile * |
2196 | bool |
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 | |
2284 | MODULE = cf PACKAGE = cf::arch |
2283 | MODULE = cf PACKAGE = cf::arch |