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.315 by root, Thu Jan 8 03:03:24 2009 UTC vs.
Revision 1.341 by root, Sun Nov 29 17:41:08 2009 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001-2005,2007 by Chachkoff Yann
6 * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de> 5 * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de>
7 * 6 *
8 * Deliantra is free software: you can redistribute it and/or modify 7 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 8 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 9 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 10 * option) any later version.
12 * 11 *
13 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 15 * GNU General Public License for more details.
17 * 16 *
18 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * and the GNU General Public License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include "autoconf.h" 24#include "autoconf.h"
71static int tick_pending; 71static int tick_pending;
72 72
73global gbl_ev; 73global gbl_ev;
74static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; 74static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
75static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; 75static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now;
76static AV *av_reflect;
76 77
77bitset<NUM_EVENT_TYPES> ev_want_event; 78bitset<NUM_EVENT_TYPES> ev_want_event;
78bitset<NUM_TYPES> ev_want_type; 79bitset<NUM_TYPES> ev_want_type;
79 80
80static HV 81static HV
88 *stash_cf_arch_wrap, 89 *stash_cf_arch_wrap,
89 *stash_cf_party_wrap, 90 *stash_cf_party_wrap,
90 *stash_cf_region_wrap, 91 *stash_cf_region_wrap,
91 *stash_cf_living_wrap; 92 *stash_cf_living_wrap;
92 93
94static SV
95 *cv_cf_do_invoke,
96 *cv_cf__can_merge,
97 *cv_cf_client_send_msg,
98 *cv_cf_tick,
99 *cv_cf_match_match;
100
93#ifndef newSVpv_utf8 101#ifndef newSVpv_utf8
94static inline SV * 102static inline SV *
95newSVpv_utf8 (const char *s) 103newSVpv_utf8 (const char *s)
96{ 104{
97 if (!s) 105 if (!s)
202attachable::destroy () 210attachable::destroy ()
203{ 211{
204 if (destroyed ()) 212 if (destroyed ())
205 return; 213 return;
206 214
207 flags |= F_DESTROYED; 215 attachable_flags |= F_DESTROYED;
208 do_destroy (); 216 do_destroy ();
209 sever_self (); 217 sever_self ();
210} 218}
211 219
212void 220void
286 294
287 attach = src.attach; 295 attach = src.attach;
288 return *this; 296 return *this;
289} 297}
290 298
299#if 0
291template<typename T> 300template<typename T>
292static bool 301static bool
293find_backref (void *ptr, T *obj) 302find_backref (void *ptr, T *obj)
294{ 303{
295 char *s = (char *)obj; 304 char *s = (char *)obj;
303 312
304 return false; 313 return false;
305} 314}
306 315
307// for debugging, find "live" objects containing this ptr 316// for debugging, find "live" objects containing this ptr
308void 317static void
309find_backref (void *ptr) 318find_backref (void *ptr)
310{ 319{
311 for_all_objects (op) 320 for_all_objects (op)
312 if (find_backref (ptr, op)) 321 if (find_backref (ptr, op))
313 fprintf (stderr, "O %p %d:'%s'\n", op, op->count, &op->name); 322 fprintf (stderr, "O %p %d:'%s'\n", op, op->count, &op->name);
317 fprintf (stderr, "P %p\n", pl); 326 fprintf (stderr, "P %p\n", pl);
318 327
319 for_all_clients (ns) 328 for_all_clients (ns)
320 if (find_backref (ptr, ns)) 329 if (find_backref (ptr, ns))
321 fprintf (stderr, "C %p\n", ns); 330 fprintf (stderr, "C %p\n", ns);
322
323} 331}
332#endif
324 333
325////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 334//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
326 335
327static SV * 336static SV *
328newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) 337newSVptr (void *ptr, HV *stash, HV *hv = newHV ())
381 390
382 return sv; 391 return sv;
383 } 392 }
384} 393}
385 394
395#if 0 // unused
386static void 396static void
387clearSVptr (SV *sv) 397clearSVptr (SV *sv)
388{ 398{
389 if (SvROK (sv)) 399 if (SvROK (sv))
390 sv = SvRV (sv); 400 sv = SvRV (sv);
391 401
392 hv_clear ((HV *)sv); 402 hv_clear ((HV *)sv);
393 sv_unmagic (sv, PERL_MAGIC_ext); 403 sv_unmagic (sv, PERL_MAGIC_ext);
394} 404}
405#endif
406
407static long SvPTR_nc (SV *sv)
408{
409 sv = SvRV (sv);
410
411 // very important shortcut
412 if (expect_true (SvMAGIC (sv) && SvMAGIC (sv)->mg_type == PERL_MAGIC_ext))
413 return (long)SvMAGIC (sv)->mg_ptr;
414
415 if (MAGIC *mg = mg_find (sv, PERL_MAGIC_ext))
416 return (long)mg->mg_ptr;
417
418 croak ("perl code used object, but C object is already destroyed, caught");
419}
395 420
396static long 421static long
397SvPTR (SV *sv, const char *klass) 422SvPTR (SV *sv, const char *klass)
398{ 423{
399 if (!sv_derived_from (sv, klass)) 424 if (!sv_derived_from (sv, klass))
400 croak ("object of type %s expected", klass); 425 croak ("object of type %s expected", klass);
401 426
402 MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext); 427 return SvPTR_nc (sv);
403
404 if (!mg)
405 croak ("perl code used %s object, but C object is already destroyed, caught", klass);
406
407 return (long)mg->mg_ptr;
408} 428}
409 429
410static long noinline 430static long noinline
411SvPTR_ornull (SV *sv, const char *klass) 431SvPTR_ornull (SV *sv, const char *klass)
412{ 432{
413 if (SvOK (sv)) 433 if (expect_false (!SvOK (sv))) return 0;
434
414 return SvPTR (sv, klass); 435 return SvPTR (sv, klass);
415 else
416 return 0;
417} 436}
418 437
438static long noinline
439SvPTR_ornull_client (SV *sv)
440{
441 if (expect_false (!SvOK (sv))) return 0;
442
443 if (!SvROK (sv)
444 || (SvSTASH (SvRV (sv)) != stash_cf_client_wrap
445 && !sv_derived_from (sv, "cf::client")))
446 croak ("object of type cf::client expected");
447
448 return SvPTR_nc (sv);
449}
450
451static long noinline
452SvPTR_ornull_object (SV *sv)
453{
454 if (expect_false (!SvOK (sv))) return 0;
455
456 if (!SvROK (sv)
457 || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap
458 && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap
459 && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap
460 && !sv_derived_from (sv, "cf::object")))
461 croak ("object of type cf::object expected");
462
463 return SvPTR_nc (sv);
464}
465
466static long noinline
467SvPTR_ornull_player (SV *sv)
468{
469 if (expect_false (!SvOK (sv))) return 0;
470
471 if (!SvROK (sv)
472 || (SvSTASH (SvRV (sv)) != stash_cf_player_wrap
473 && !sv_derived_from (sv, "cf::player")))
474 croak ("object of type cf::player expected");
475
476 return SvPTR_nc (sv);
477}
478
419inline SV *to_sv (const shstr & v) { return newSVpvn_utf8 ((const char *)v, v.length (), 1); } 479static inline SV *to_sv (const shstr & v) { return newSVpvn_utf8 ((const char *)v, v.length (), 1); }
420inline SV *to_sv (const char * v) { return v ? newSVpv (v, 0) : newSV (0); } 480static inline SV *to_sv (const char * v) { return v ? newSVpv (v, 0) : newSV (0); }
421inline SV *to_sv (bool v) { return newSViv (v); } 481static inline SV *to_sv (bool v) { return newSViv (v); }
422inline SV *to_sv ( signed char v) { return newSViv (v); } 482static inline SV *to_sv ( signed char v) { return newSViv (v); }
423inline SV *to_sv (unsigned char v) { return newSViv (v); } 483static inline SV *to_sv (unsigned char v) { return newSViv (v); }
424inline SV *to_sv ( signed short v) { return newSViv (v); } 484static inline SV *to_sv ( signed short v) { return newSViv (v); }
425inline SV *to_sv (unsigned short v) { return newSVuv (v); } 485static inline SV *to_sv (unsigned short v) { return newSVuv (v); }
426inline SV *to_sv ( signed int v) { return newSViv (v); } 486static inline SV *to_sv ( signed int v) { return newSViv (v); }
427inline SV *to_sv (unsigned int v) { return newSVuv (v); } 487static inline SV *to_sv (unsigned int v) { return newSVuv (v); }
428inline SV *to_sv ( signed long v) { return newSViv (v); } 488static inline SV *to_sv ( signed long v) { return newSViv (v); }
429inline SV *to_sv (unsigned long v) { return newSVuv (v); } 489static inline SV *to_sv (unsigned long v) { return newSVuv (v); }
430inline SV *to_sv ( signed long long v) { return newSVval64 (v); } 490static inline SV *to_sv ( signed long long v) { return newSVval64 (v); }
431inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 491static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
432inline SV *to_sv (float v) { return newSVnv (v); } 492static inline SV *to_sv (float v) { return newSVnv (v); }
433inline SV *to_sv (double v) { return newSVnv (v); } 493static inline SV *to_sv (double v) { return newSVnv (v); }
434inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } 494static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); }
435inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } 495static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); }
436inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } 496static inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); }
437inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 497static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); }
438inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 498static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
439inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } 499static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
440inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 500static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
441inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 501static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
442inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } 502static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); }
443 503
444inline SV *to_sv (object & v) { return to_sv (&v); } 504static inline SV *to_sv (object & v) { return to_sv (&v); }
445inline SV *to_sv (living & v) { return to_sv (&v); } 505static inline SV *to_sv (living & v) { return to_sv (&v); }
446 506
447inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 507static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
448inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } 508static inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); }
449 509
450inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } 510static inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); }
451 511
452inline SV *to_sv (dynbuf * v) 512static inline SV *to_sv (dynbuf * v)
453{ 513{
454 SV *sv = newSV (0); 514 SV *sv = newSV (0);
455 515
456 sv_upgrade (sv, SVt_PV); 516 sv_upgrade (sv, SVt_PV);
457 SvGROW (sv, v->size () + 1); 517 SvGROW (sv, v->size () + 1);
461 *SvEND (sv) = 0; 521 *SvEND (sv) = 0;
462 522
463 return sv; 523 return sv;
464} 524}
465 525
466inline SV *to_sv (dynbuf_text * v) 526static inline SV *to_sv (dynbuf_text * v)
467{ 527{
468 SV *sv = to_sv (static_cast<dynbuf *> (v)); 528 SV *sv = to_sv (static_cast<dynbuf *> (v));
469 SvUTF8_on (sv); 529 SvUTF8_on (sv);
470 return sv; 530 return sv;
471} 531}
472 532
473inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } 533static inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; }
474inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 534static inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
475inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 535static inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
476inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 536static inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
477inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } 537static inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); }
478inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } 538static inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); }
479inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } 539static inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); }
480inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } 540static inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); }
481inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } 541static inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); }
482inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } 542static inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); }
483inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } 543static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); }
484inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } 544static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); }
485inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } 545static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); }
486inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 546static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
487inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 547static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); }
488inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } 548static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); }
489inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } 549static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); }
490inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } 550static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); }
491inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } 551static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); }
492inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } 552static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull (sv, "cf::map"); }
493inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } 553static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); }
494inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 554static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
495inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 555static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); }
496inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 556static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); }
497inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *)SvPTR_ornull (sv, "cf::mapspace"); } 557static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); }
498inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *)SvPTR_ornull (sv, "cf::object::freezer"); } 558static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); }
499inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *)SvPTR_ornull (sv, "cf::object::thawer" ); } 559static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); }
500 560
501//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 561//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
502inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 562static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); }
503 563
504template<class T> 564template<class T>
505inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 565static inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
506 566
507template<int N> 567template<int N>
508inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } 568static inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
509 569
510inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } 570static inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); }
511inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } 571static inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); }
512inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } 572static inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
513inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } 573static inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
514 574
515inline void sv_to (SV *sv, std::string &v) 575static inline void sv_to (SV *sv, std::string &v)
516{ 576{
517 STRLEN len; 577 STRLEN len;
518 char *data = SvPVbyte (sv, len); 578 char *data = SvPVbyte (sv, len);
519 v.assign (data, len); 579 v.assign (data, len);
520} 580}
521 581
522inline void sv_to (SV *sv, UUID &v) 582static inline void sv_to (SV *sv, UUID &v)
523{ 583{
524 if (!v.parse (SvPV_nolen (sv))) 584 if (!v.parse (SvPV_nolen (sv)))
525 croak ("unparsable uuid: %s", SvPV_nolen (sv)); 585 croak ("unparsable uuid: %s", SvPV_nolen (sv));
526} 586}
527 587
528inline void sv_to (SV *sv, object::flags_t::reference v) { v = SvTRUE (sv); } 588static inline void sv_to (SV *sv, object::flags_t::reference v) { v = SvTRUE (sv); }
529 589
530static SV * 590static SV *
531newSVdt_va (va_list &ap, data_type type) 591newSVdt_va (va_list &ap, data_type type)
532{ 592{
533 SV *sv; 593 SV *sv;
633 var = 0; 693 var = 0;
634} 694}
635 695
636////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 696//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
637 697
638SV * 698static SV *
639registry (attachable *ext) 699registry (attachable *ext)
640{ 700{
641 if (!ext->cb) 701 if (!ext->cb)
642 ext->cb = newAV (); 702 ext->cb = newAV ();
643 703
919 XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); 979 XPUSHs (sv_2mortal (newSVdt_va (ap, dt)));
920 } 980 }
921 981
922 va_end (ap); 982 va_end (ap);
923 983
924 CALL_CALL ("cf::do_invoke", G_SCALAR); 984 CALL_CALL (cv_cf_do_invoke, G_SCALAR);
925 count = count > 0 ? POPi : 0; 985 count = count > 0 ? POPi : 0;
926 986
927 CALL_END; 987 CALL_END;
928 988
929 return count; 989 return count;
930} 990}
931 991
932SV * 992static SV *
933cfperl_result (int idx) 993cfperl_result (int idx)
934{ 994{
935 AV *av = get_av ("cf::INVOKE_RESULTS", 0); 995 AV *av = get_av ("cf::INVOKE_RESULTS", 0);
936 if (!av) 996 if (!av)
937 return &PL_sv_undef; 997 return &PL_sv_undef;
970 1030
971 dSP; 1031 dSP;
972 1032
973 PUSHMARK (SP); 1033 PUSHMARK (SP);
974 PUTBACK; 1034 PUTBACK;
975 call_pv ("cf::tick", G_DISCARD | G_VOID); 1035 call_pvsv (cv_cf_tick, G_DISCARD | G_VOID);
976 1036
977 SvNV_set (sv_next_tick, get_next_tick ()); SvNOK_only (sv_next_tick); 1037 SvNV_set (sv_next_tick, get_next_tick ()); SvNOK_only (sv_next_tick);
978} 1038}
979 1039
980void 1040void
1010 CALL_BEGIN (4); 1070 CALL_BEGIN (4);
1011 CALL_ARG (ns); 1071 CALL_ARG (ns);
1012 CALL_ARG (type); 1072 CALL_ARG (type);
1013 CALL_ARG_SV (newSVpv_utf8 (msg)); 1073 CALL_ARG_SV (newSVpv_utf8 (msg));
1014 CALL_ARG (color); 1074 CALL_ARG (color);
1015 CALL_CALL ("cf::client::send_msg", G_VOID); 1075 CALL_CALL (cv_cf_client_send_msg, G_VOID);
1016 CALL_END; 1076 CALL_END;
1017} 1077}
1018 1078
1019int 1079int
1020cfperl_can_merge (object *ob1, object *ob2) 1080cfperl_can_merge (object *ob1, object *ob2)
1022 int can; 1082 int can;
1023 1083
1024 CALL_BEGIN (2); 1084 CALL_BEGIN (2);
1025 CALL_ARG (ob1); 1085 CALL_ARG (ob1);
1026 CALL_ARG (ob2); 1086 CALL_ARG (ob2);
1027 CALL_CALL ("cf::_can_merge", G_SCALAR); 1087 CALL_CALL (cv_cf__can_merge, G_SCALAR);
1028 can = count && SvTRUE (TOPs); 1088 can = count && SvTRUE (TOPs);
1029 CALL_END; 1089 CALL_END;
1030 1090
1031 return can; 1091 return can;
1032} 1092}
1033 1093
1034void 1094void
1035cfperl_mapscript_activate (object *ob, object *activator, int state) 1095cfperl_mapscript_activate (object *ob, int state, object *activator, object *originator)
1036{ 1096{
1037 CALL_BEGIN (3); 1097 CALL_BEGIN (4);
1038 CALL_ARG (ob); 1098 CALL_ARG (ob);
1099 CALL_ARG (state);
1039 CALL_ARG (activator); 1100 CALL_ARG (activator);
1040 CALL_ARG (state); 1101 CALL_ARG (originator);
1041 CALL_CALL ("cf::mapscript::activate", G_VOID); 1102 CALL_CALL ("cf::mapscript::activate", G_VOID);
1042 CALL_END; 1103 CALL_END;
1043} 1104}
1044 1105
1045player * 1106player *
1187 CALL_CALL ("cf::_log_backtrace", G_VOID); 1248 CALL_CALL ("cf::_log_backtrace", G_VOID);
1188 CALL_END; 1249 CALL_END;
1189#endif 1250#endif
1190} 1251}
1191 1252
1253bool
1254is_match_expr (const char *expr)
1255{
1256 return !strncmp (expr, "match ", sizeof ("match ") - 1);
1257}
1258
1259bool
1260match (const char *expr, object *ob, object *self, object *source, object *originator)
1261{
1262 if (!strncmp (expr, "match ", sizeof ("match ") - 1))
1263 expr += sizeof ("match ") - 1;
1264
1265 CALL_BEGIN (5);
1266 CALL_ARG (expr);
1267 CALL_ARG (ob);
1268 CALL_ARG (self);
1269 CALL_ARG (source);
1270 CALL_ARG (originator);
1271 CALL_CALL (cv_cf_match_match, G_SCALAR);
1272
1273 bool matched = count && SvTRUE (TOPs);
1274
1275 CALL_END;
1276
1277 return matched;
1278}
1279
1280object *
1281match_one (const char *expr, object *ob, object *self, object *source, object *originator)
1282{
1283 if (!strncmp (expr, "match ", sizeof ("match ") - 1))
1284 expr += sizeof ("match ") - 1;
1285
1286 CALL_BEGIN (5);
1287 CALL_ARG (expr);
1288 CALL_ARG (ob);
1289 CALL_ARG (self);
1290 CALL_ARG (source);
1291 CALL_ARG (originator);
1292 CALL_CALL (cv_cf_match_match, G_ARRAY);
1293
1294 object *one = 0;
1295
1296 if (count)
1297 sv_to (TOPs, one);
1298
1299 CALL_END;
1300
1301 return one;
1302}
1303
1192///////////////////////////////////////////////////////////////////////////// 1304/////////////////////////////////////////////////////////////////////////////
1193 1305
1194struct EVAPI *evapi::GEVAPI; 1306struct EVAPI *evapi::GEVAPI;
1195struct CoroAPI *coroapi::GCoroAPI; 1307struct CoroAPI *coroapi::GCoroAPI;
1196 1308
1228 if (active) start (); 1340 if (active) start ();
1229 } 1341 }
1230} 1342}
1231 1343
1232static void 1344static void
1233_connect_to_perl () 1345_connect_to_perl_1 ()
1234{ 1346{
1235 stash_cf = gv_stashpv ("cf", 1); 1347 stash_cf = gv_stashpv ("cf", 1);
1236 1348
1237 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1349 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1238 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); 1350 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1);
1257 cb_client = get_av ("cf::CB_CLIENT", 1); 1369 cb_client = get_av ("cf::CB_CLIENT", 1);
1258 cb_type = get_av ("cf::CB_TYPE" , 1); 1370 cb_type = get_av ("cf::CB_TYPE" , 1);
1259 cb_map = get_av ("cf::CB_MAP" , 1); 1371 cb_map = get_av ("cf::CB_MAP" , 1);
1260} 1372}
1261 1373
1374static void
1375_connect_to_perl_2 ()
1376{
1377 cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke);
1378 cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge);
1379 cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg);
1380 cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick);
1381 cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match);
1382}
1383
1262MODULE = cf PACKAGE = cf PREFIX = cf_ 1384MODULE = cf PACKAGE = cf PREFIX = cf_
1263 1385
1264BOOT: 1386BOOT:
1265{ 1387{
1266 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; 1388 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI;
1267 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1389 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1268 1390
1269 _connect_to_perl (); 1391 _connect_to_perl_1 ();
1270 1392
1271 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1393 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1272 1394
1273 //{ 1395 //{
1274 // require_pv ("Time::HiRes"); 1396 // require_pv ("Time::HiRes");
1318 const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR) 1440 const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR)
1319 const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH) 1441 const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH)
1320 const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL) 1442 const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL)
1321 const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK) 1443 const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK)
1322 const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON) 1444 const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON)
1323 const_iv (CF_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN) 1445 const_iv (T_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN)
1324 const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT) 1446 const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT)
1325 const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED) 1447 const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED)
1326 const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE) 1448 const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE)
1327 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) 1449 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON)
1328 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) 1450 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL)
1354 const_iv (FLAG_GENERATOR) const_iv (FLAG_IS_THROWN) const_iv (FLAG_AUTO_APPLY) const_iv (FLAG_PLAYER_SOLD) 1476 const_iv (FLAG_GENERATOR) const_iv (FLAG_IS_THROWN) const_iv (FLAG_AUTO_APPLY) const_iv (FLAG_PLAYER_SOLD)
1355 const_iv (FLAG_SEE_INVISIBLE) const_iv (FLAG_CAN_ROLL) const_iv (FLAG_OVERLAY_FLOOR) const_iv (FLAG_IS_TURNABLE) 1477 const_iv (FLAG_SEE_INVISIBLE) const_iv (FLAG_CAN_ROLL) const_iv (FLAG_OVERLAY_FLOOR) const_iv (FLAG_IS_TURNABLE)
1356 const_iv (FLAG_IS_USED_UP) const_iv (FLAG_IDENTIFIED) const_iv (FLAG_REFLECTING) const_iv (FLAG_CHANGING) 1478 const_iv (FLAG_IS_USED_UP) const_iv (FLAG_IDENTIFIED) const_iv (FLAG_REFLECTING) const_iv (FLAG_CHANGING)
1357 const_iv (FLAG_SPLITTING) const_iv (FLAG_HITBACK) const_iv (FLAG_STARTEQUIP) const_iv (FLAG_BLOCKSVIEW) 1479 const_iv (FLAG_SPLITTING) const_iv (FLAG_HITBACK) const_iv (FLAG_STARTEQUIP) const_iv (FLAG_BLOCKSVIEW)
1358 const_iv (FLAG_UNDEAD) const_iv (FLAG_SCARED) const_iv (FLAG_UNAGGRESSIVE) const_iv (FLAG_REFL_MISSILE) 1480 const_iv (FLAG_UNDEAD) const_iv (FLAG_SCARED) const_iv (FLAG_UNAGGRESSIVE) const_iv (FLAG_REFL_MISSILE)
1359 const_iv (FLAG_REFL_SPELL) const_iv (FLAG_NO_MAGIC) const_iv (FLAG_NO_FIX_PLAYER) const_iv (FLAG_IS_LIGHTABLE) 1481 const_iv (FLAG_REFL_SPELL) const_iv (FLAG_NO_MAGIC) const_iv (FLAG_IS_LIGHTABLE)
1360 const_iv (FLAG_TEAR_DOWN) const_iv (FLAG_RUN_AWAY) const_iv (FLAG_PICK_UP) const_iv (FLAG_UNIQUE) 1482 const_iv (FLAG_TEAR_DOWN) const_iv (FLAG_RUN_AWAY) const_iv (FLAG_PICK_UP) const_iv (FLAG_UNIQUE)
1361 const_iv (FLAG_NO_DROP) const_iv (FLAG_WIZCAST) const_iv (FLAG_CAST_SPELL) const_iv (FLAG_USE_SCROLL) 1483 const_iv (FLAG_NO_DROP) const_iv (FLAG_WIZCAST) const_iv (FLAG_CAST_SPELL) const_iv (FLAG_USE_SCROLL)
1362 const_iv (FLAG_USE_RANGE) const_iv (FLAG_USE_BOW) const_iv (FLAG_USE_ARMOUR) const_iv (FLAG_USE_WEAPON) 1484 const_iv (FLAG_USE_RANGE) const_iv (FLAG_USE_BOW) const_iv (FLAG_USE_ARMOUR) const_iv (FLAG_USE_WEAPON)
1363 const_iv (FLAG_USE_RING) const_iv (FLAG_READY_RANGE) const_iv (FLAG_READY_BOW) const_iv (FLAG_XRAYS) 1485 const_iv (FLAG_USE_RING) const_iv (FLAG_READY_RANGE) const_iv (FLAG_READY_BOW) const_iv (FLAG_XRAYS)
1364 const_iv (FLAG_NO_APPLY) const_iv (FLAG_IS_FLOOR) const_iv (FLAG_LIFESAVE) const_iv (FLAG_NO_STRENGTH) 1486 const_iv (FLAG_NO_APPLY) const_iv (FLAG_IS_FLOOR) const_iv (FLAG_LIFESAVE) const_iv (FLAG_NO_STRENGTH)
1546 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1668 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1547 av_push (event, newSViv (eiv->klass)); 1669 av_push (event, newSViv (eiv->klass));
1548 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1670 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1549 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1671 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1550 } 1672 }
1673
1674 // used by autogenerated BOOT sections from genacc
1675 av_reflect = get_av ("cf::REFLECT", 1);
1551} 1676}
1552 1677
1553void _gv_clear (SV *gv) 1678void _gv_clear (SV *gv)
1554 CODE: 1679 CODE:
1555 assert (SvTYPE (gv) == SVt_PVGV); 1680 assert (SvTYPE (gv) == SVt_PVGV);
1562 f (GvGP (gv)->gp_cv); 1687 f (GvGP (gv)->gp_cv);
1563 GvCVGEN (gv) = 0; 1688 GvCVGEN (gv) = 0;
1564 GvMULTI_off (gv); 1689 GvMULTI_off (gv);
1565# undef f 1690# undef f
1566 1691
1567void _connect_to_perl () 1692void _connect_to_perl_1 ()
1693
1694void _connect_to_perl_2 ()
1568 1695
1569void _recalc_want () 1696void _recalc_want ()
1570 1697
1571# not used by default anymore 1698# not used by default anymore
1572void _global_reattach () 1699void _global_reattach ()
1937 RETVAL 2064 RETVAL
1938 2065
1939void 2066void
1940debug_trace (attachable *obj, bool on = true) 2067debug_trace (attachable *obj, bool on = true)
1941 CODE: 2068 CODE:
1942 obj->flags &= ~attachable::F_DEBUG_TRACE; 2069 obj->attachable_flags &= ~attachable::F_DEBUG_TRACE;
1943 if (on) 2070 if (on)
1944 obj->flags |= attachable::F_DEBUG_TRACE; 2071 obj->attachable_flags |= attachable::F_DEBUG_TRACE;
1945 2072
1946int mortals_size () 2073int mortals_size ()
1947 CODE: 2074 CODE:
1948 RETVAL = attachable::mortals.size (); 2075 RETVAL = attachable::mortals.size ();
1949 OUTPUT: RETVAL 2076 OUTPUT: RETVAL
2090 CODE: 2217 CODE:
2091 player_apply_below (op); 2218 player_apply_below (op);
2092 2219
2093int cast_heal (object *op, object *caster, object *spell, int dir = 0) 2220int cast_heal (object *op, object *caster, object *spell, int dir = 0)
2094 2221
2222int casting_level (object *caster, object *spell)
2223
2095int pay_item (object *op, object *buyer) 2224int pay_item (object *op, object *buyer)
2096 CODE: 2225 CODE:
2097 RETVAL = pay_for_item (op, buyer); 2226 RETVAL = pay_for_item (op, buyer);
2098 OUTPUT: RETVAL 2227 OUTPUT: RETVAL
2099 2228
2141 2270
2142void player_lvl_adj (object *who, object *skill = 0) 2271void player_lvl_adj (object *who, object *skill = 0)
2143 2272
2144int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 2273int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
2145 2274
2146int calc_skill_exp (object *who, object *op, object *skill); 2275int calc_skill_exp (object *who, object *op, object *skill)
2147 2276
2148void push_button (object *op); 2277void push_button (object *op, object *originator)
2149 2278
2150void use_trigger (object *op); 2279void use_trigger (object *op, object *originator)
2151 2280
2152void handle_apply_yield (object *op); 2281void handle_apply_yield (object *op)
2282
2283int convert_item (object *item, object *converter)
2153 2284
2154 2285
2155MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2286MODULE = cf PACKAGE = cf::object PREFIX = cf_
2156 2287
2157# no clean way to get an object from an archetype - stupid idiotic 2288# no clean way to get an object from an archetype - stupid idiotic
2170object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) 2301object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
2171 PROTOTYPE: $$$$$$ 2302 PROTOTYPE: $$$$$$
2172 CODE: 2303 CODE:
2173{ 2304{
2174 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2305 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2306
2307 if (RETVAL->destroyed ())
2308 RETVAL = 0;
2175} 2309}
2176 2310
2177shstr 2311shstr
2178object::kv_get (shstr key) 2312object::kv_get (shstr key)
2179 2313
2363void 2497void
2364adjust_daylight () 2498adjust_daylight ()
2365 CODE: 2499 CODE:
2366 maptile::adjust_daylight (); 2500 maptile::adjust_daylight ();
2367 2501
2502int
2503outdoor_darkness (int darkness = 0)
2504 CODE:
2505 RETVAL = maptile::outdoor_darkness;
2506 if (items)
2507 maptile::outdoor_darkness = darkness;
2508 OUTPUT:
2509 RETVAL
2510
2368void 2511void
2369maptile::instantiate () 2512maptile::instantiate ()
2370 2513
2371maptile *new () 2514maptile *new ()
2372 PROTOTYPE: 2515 PROTOTYPE:
2403 for (int x = 0; x < THIS->width; ++x) 2546 for (int x = 0; x < THIS->width; ++x)
2404 for (int y = 0; y < THIS->height; ++y) 2547 for (int y = 0; y < THIS->height; ++y)
2405 { 2548 {
2406 for (object *op = THIS->at (x, y).bot; op; op = op->above) 2549 for (object *op = THIS->at (x, y).bot; op; op = op->above)
2407 if (op->flag [FLAG_IS_FLOOR]) 2550 if (op->flag [FLAG_IS_FLOOR])
2408 goto skip_space; 2551 goto skip;
2409 2552
2410 { 2553 {
2411 int offs = offset + y * stride + x; 2554 int offs = offset + y * stride + x;
2555
2412 if (IN_RANGE_EXC (offs, 0, idxlen)) 2556 if (IN_RANGE_EXC (offs, 0, idxlen))
2413 { 2557 {
2414 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2558 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2415 { 2559 {
2416 object *ob = get_archetype (SvPVutf8_nolen (*elem)); 2560 object *ob = get_archetype (SvPVutf8_nolen (*elem));
2417 ob->flag [FLAG_NO_MAP_SAVE] = true; 2561 ob->flag [FLAG_NO_MAP_SAVE] = true;
2418 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2562 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2419 2563
2420 if (ob->randomitems) 2564 if (ob->randomitems && !ob->above)
2421 { 2565 {
2422 if (!ob->above)
2423 {
2424 ob->create_treasure (ob->randomitems); 2566 ob->create_treasure (ob->randomitems);
2425 2567
2426 for (object *op = ob->above; op; op = op->above) 2568 for (object *op = ob->above; op; op = op->above)
2427 op->flag [FLAG_NO_MAP_SAVE] = true; 2569 op->flag [FLAG_NO_MAP_SAVE] = true;
2428 } 2570 // TODO: if this is a pickable object, then the item
2429 2571 // will at a bit weird - saving inside the player
2430 ob->randomitems = 0; 2572 // will clear the flag, but when the player drops
2573 // it without logging out, it keeps the flag.
2574 // nobody ahs reported this, but this can be rather
2575 // annoying on persistent maps.
2431 } 2576 }
2432 } 2577 }
2433 } 2578 }
2434 } 2579 }
2435 2580
2436 skip_space: ; 2581 skip: ;
2437 } 2582 }
2438} 2583}
2439 2584
2440void 2585void
2441maptile::set_regiondata (SV *data, int offset, int stride, SV *palette) 2586maptile::set_regiondata (SV *data, int offset, int stride, SV *palette)
2581 case 6: RETVAL = newSVuv (ms.move_on ); break; 2726 case 6: RETVAL = newSVuv (ms.move_on ); break;
2582 case 7: RETVAL = newSVuv (ms.move_off ); break; 2727 case 7: RETVAL = newSVuv (ms.move_off ); break;
2583 } 2728 }
2584} 2729}
2585 OUTPUT: RETVAL 2730 OUTPUT: RETVAL
2586
2587void fix_walls (maptile *map, int x, int y)
2588
2589void fix_walls_around (maptile *map, int x, int y)
2590 2731
2591# worst xs function of my life 2732# worst xs function of my life
2592bool 2733bool
2593_create_random_map (\ 2734_create_random_map (\
2594 maptile *self,\ 2735 maptile *self,\
2690archetype *archetypes (U32 index) 2831archetype *archetypes (U32 index)
2691 CODE: 2832 CODE:
2692 RETVAL = index < archetypes.size () ? archetypes [index] : 0; 2833 RETVAL = index < archetypes.size () ? archetypes [index] : 0;
2693 OUTPUT: RETVAL 2834 OUTPUT: RETVAL
2694 2835
2695object *instantiate (archetype *arch)
2696 CODE:
2697 RETVAL = arch_to_object (arch);
2698 OUTPUT:
2699 RETVAL
2700
2701INCLUDE: $PERL $srcdir/genacc archetype ../include/object.h | 2836INCLUDE: $PERL $srcdir/genacc archetype ../include/object.h |
2702 2837
2703MODULE = cf PACKAGE = cf::party 2838MODULE = cf PACKAGE = cf::party
2704 2839
2705partylist *first () 2840partylist *first ()
2865 faceinfo *f = face_info (idx); assert (f); 3000 faceinfo *f = face_info (idx); assert (f);
2866 facedata *d = &(faceset ? f->data64 : f->data32); 3001 facedata *d = &(faceset ? f->data64 : f->data32);
2867 sv_to (data, d->data); 3002 sv_to (data, d->data);
2868 STRLEN clen; 3003 STRLEN clen;
2869 char *cdata = SvPVbyte (chksum, clen); 3004 char *cdata = SvPVbyte (chksum, clen);
2870 clen = min (CHKSUM_SIZE, clen); 3005 clen = min (CHKSUM_MAXLEN, clen);
2871 3006
2872 if (memcmp (d->chksum, cdata, clen)) 3007 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen))
2873 { 3008 {
3009 d->chksum_len = clen;
2874 memcpy (d->chksum, cdata, clen); 3010 memcpy (d->chksum, cdata, clen);
2875 3011
2876 // invalidate existing client face info 3012 // invalidate existing client face info
2877 for_all_clients (ns) 3013 for_all_clients (ns)
2878 if (ns->faceset == faceset) 3014 if (ns->faceset == faceset)
2893 3029
2894SV *get_chksum (faceidx idx, int faceset = 0) 3030SV *get_chksum (faceidx idx, int faceset = 0)
2895 CODE: 3031 CODE:
2896 facedata *d = face_data (idx, faceset); 3032 facedata *d = face_data (idx, faceset);
2897 if (!d) XSRETURN_UNDEF; 3033 if (!d) XSRETURN_UNDEF;
2898 RETVAL = newSVpvn ((char *)d->chksum, CHKSUM_SIZE); 3034 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2899 OUTPUT: 3035 OUTPUT:
2900 RETVAL 3036 RETVAL
2901 3037
2902SV *get_data (faceidx idx, int faceset = 0) 3038SV *get_data (faceidx idx, int faceset = 0)
2903 CODE: 3039 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines