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.197 by root, Fri Apr 27 03:38:33 2007 UTC vs.
Revision 1.204 by root, Mon Apr 30 04:25:30 2007 UTC

21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */ 24 */
25 25
26#include "autoconf.h"
27
26#define PLUGIN_NAME "perl" 28#define PLUGIN_NAME "perl"
27#define PLUGIN_VERSION "cfperl 0.5" 29#define PLUGIN_VERSION "cfperl 0.5"
28 30
29#define CEDES_PER_TICK 5 31#define CEDES_PER_TICK 5
32
33#if HAVE_EXECINFO_H
34# include <execinfo.h>
35#endif
30 36
31#include <plugin_common.h> 37#include <plugin_common.h>
32#include <sounds.h> 38#include <sounds.h>
33#include <cstdarg> 39#include <cstdarg>
34#include <sproto.h> 40#include <sproto.h>
180 if (destroyed ()) 186 if (destroyed ())
181 return; 187 return;
182 188
183 flags |= F_DESTROYED; 189 flags |= F_DESTROYED;
184 do_destroy (); 190 do_destroy ();
191 sever_self ();
185} 192}
186 193
187void 194void
188attachable::check_mortals () 195attachable::check_mortals ()
189{ 196{
209 LOG (llevError, "check_mortals: object '%s' still has self\n", typeid (obj).name ()); 216 LOG (llevError, "check_mortals: object '%s' still has self\n", typeid (obj).name ());
210 obj->sever_self (); 217 obj->sever_self ();
211 } 218 }
212#endif 219#endif
213 220
214 if (obj->refcnt_cnt ()) 221 if (obj->refcnt)
215 { 222 {
216 ++i; // further delay freeing 223 ++i; // further delay freeing
217 224
218 if (!(i & 0x3ff)) 225 if (!(i & 0x3ff))
219 break; 226 break;
397inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 404inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
398 405
399template<int N> 406template<int N>
400inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } 407inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
401 408
402inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); }
403inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } 409inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); }
404inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } 410inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); }
405inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } 411inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
406inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } 412inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
407 413
610 perl_construct (perl); 616 perl_construct (perl);
611 617
612 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 618 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
613 619
614 const char *argv[] = { 620 const char *argv[] = {
615 "", 621 settings.argv [0],
616 "-e" 622 "-e"
617 "use Event; use Coro;" // required for bootstrap 623 "use Event; use Coro;" // required for bootstrap
618 "cf->bootstrap;" // required for datadir :*> 624 "cf->bootstrap;" // required for datadir :*>
619 "unshift @INC, cf::datadir ();" 625 "unshift @INC, cf::datadir ();"
620 "require cf;" 626 "require cf;"
942 CALL_ARG (exit); 948 CALL_ARG (exit);
943 CALL_CALL ("cf::object::player::enter_exit", G_VOID); 949 CALL_CALL ("cf::object::player::enter_exit", G_VOID);
944 CALL_END; 950 CALL_END;
945} 951}
946 952
953void
954log_backtrace (const char *msg)
955{
956#if HAVE_BACKTRACE
957 void *addr [20];
958 int size = backtrace (addr, 20);
959
960 CALL_BEGIN (size);
961 CALL_ARG (msg);
962 for (int i = 0; i < size; ++i)
963 CALL_ARG ((IV)addr [i]);
964 CALL_CALL ("cf::_log_backtrace", G_VOID);
965 CALL_END;
966#endif
967}
968
947///////////////////////////////////////////////////////////////////////////// 969/////////////////////////////////////////////////////////////////////////////
948 970
949struct EventAPI *watcher_base::GEventAPI; 971struct EventAPI *watcher_base::GEventAPI;
950struct CoroAPI *coroapi::GCoroAPI; 972struct CoroAPI *coroapi::GCoroAPI;
951 973
1105 const char *name; 1127 const char *name;
1106 IV iv; 1128 IV iv;
1107 } *civ, const_iv[] = { 1129 } *civ, const_iv[] = {
1108# define const_iv(name) { # name, (IV)name }, 1130# define const_iv(name) { # name, (IV)name },
1109 const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) 1131 const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster)
1132 const_iv (logBacktrace)
1110 1133
1111 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1134 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1112 1135
1113 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1136 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1114 1137
1386 CODE: 1409 CODE:
1387 runtime = SvNVx (sv_runtime); 1410 runtime = SvNVx (sv_runtime);
1388 server_tick (); 1411 server_tick ();
1389 1412
1390void 1413void
1414log_backtrace (utf8_string msg)
1415
1416void
1391LOG (int level, utf8_string msg) 1417LOG (int flags, utf8_string msg)
1392 PROTOTYPE: $$ 1418 PROTOTYPE: $$
1393 C_ARGS: (LogLevel)level, "%s", msg 1419 C_ARGS: flags, "%s", msg
1394 1420
1395octet_string path_combine (octet_string base, octet_string path) 1421octet_string path_combine (octet_string base, octet_string path)
1396 PROTOTYPE: $$ 1422 PROTOTYPE: $$
1397 1423
1398octet_string path_combine_and_normalize (octet_string base, octet_string path) 1424octet_string path_combine_and_normalize (octet_string base, octet_string path)
1435 } 1461 }
1436 OUTPUT: RETVAL 1462 OUTPUT: RETVAL
1437 1463
1438void abort () 1464void abort ()
1439 1465
1466void reset_signals ()
1467
1440void fork_abort (octet_string cause = "cf::fork_abort") 1468void fork_abort (octet_string cause = "cf::fork_abort")
1441 1469
1442void cleanup (octet_string cause, bool make_core = false) 1470void cleanup (octet_string cause, bool make_core = false)
1443 1471
1444void emergency_save () 1472void emergency_save ()
1970 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 1998 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
1971 { 1999 {
1972 object *ob = get_archetype (SvPVutf8_nolen (*elem)); 2000 object *ob = get_archetype (SvPVutf8_nolen (*elem));
1973 ob->flag [FLAG_NO_MAP_SAVE] = true; 2001 ob->flag [FLAG_NO_MAP_SAVE] = true;
1974 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2002 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2003
2004 if (ob->randomitems)
2005 {
2006 if (!ob->above)
2007 {
2008 ob->create_treasure (ob->randomitems);
2009
2010 for (object *op = ob->above; op; op = op->above)
2011 op->flag [FLAG_NO_MAP_SAVE] = true;
2012 }
2013
2014 ob->randomitems = 0;
2015 }
1975 } 2016 }
1976 } 2017 }
1977 } 2018 }
1978 2019
1979 skip_space: ; 2020 skip_space: ;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines