… | |
… | |
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 | |
187 | void |
194 | void |
188 | attachable::check_mortals () |
195 | attachable::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; |
… | |
… | |
610 | perl_construct (perl); |
617 | perl_construct (perl); |
611 | |
618 | |
612 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
619 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
613 | |
620 | |
614 | const char *argv[] = { |
621 | const char *argv[] = { |
615 | "", |
622 | settings.argv [0], |
616 | "-e" |
623 | "-e" |
617 | "use Event; use Coro;" // required for bootstrap |
624 | "use Event; use Coro;" // required for bootstrap |
618 | "cf->bootstrap;" // required for datadir :*> |
625 | "cf->bootstrap;" // required for datadir :*> |
619 | "unshift @INC, cf::datadir ();" |
626 | "unshift @INC, cf::datadir ();" |
620 | "require cf;" |
627 | "require cf;" |
… | |
… | |
942 | CALL_ARG (exit); |
949 | CALL_ARG (exit); |
943 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
950 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
944 | CALL_END; |
951 | CALL_END; |
945 | } |
952 | } |
946 | |
953 | |
|
|
954 | void |
|
|
955 | log_backtrace (const char *msg) |
|
|
956 | { |
|
|
957 | #if HAVE_BACKTRACE |
|
|
958 | void *addr [20]; |
|
|
959 | int size = backtrace (addr, 20); |
|
|
960 | |
|
|
961 | CALL_BEGIN (size); |
|
|
962 | CALL_ARG (msg); |
|
|
963 | for (int i = 0; i < size; ++i) |
|
|
964 | CALL_ARG ((IV)addr [i]); |
|
|
965 | CALL_CALL ("cf::_log_backtrace", G_VOID); |
|
|
966 | CALL_END; |
|
|
967 | #endif |
|
|
968 | } |
|
|
969 | |
947 | ///////////////////////////////////////////////////////////////////////////// |
970 | ///////////////////////////////////////////////////////////////////////////// |
948 | |
971 | |
949 | struct EventAPI *watcher_base::GEventAPI; |
972 | struct EventAPI *watcher_base::GEventAPI; |
950 | struct CoroAPI *coroapi::GCoroAPI; |
973 | struct CoroAPI *coroapi::GCoroAPI; |
951 | |
974 | |
… | |
… | |
1105 | const char *name; |
1128 | const char *name; |
1106 | IV iv; |
1129 | IV iv; |
1107 | } *civ, const_iv[] = { |
1130 | } *civ, const_iv[] = { |
1108 | # define const_iv(name) { # name, (IV)name }, |
1131 | # define const_iv(name) { # name, (IV)name }, |
1109 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
1132 | const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) |
|
|
1133 | const_iv (logBacktrace) |
1110 | |
1134 | |
1111 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1135 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1112 | |
1136 | |
1113 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1137 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1114 | |
1138 | |
… | |
… | |
1386 | CODE: |
1410 | CODE: |
1387 | runtime = SvNVx (sv_runtime); |
1411 | runtime = SvNVx (sv_runtime); |
1388 | server_tick (); |
1412 | server_tick (); |
1389 | |
1413 | |
1390 | void |
1414 | void |
|
|
1415 | log_backtrace (utf8_string msg) |
|
|
1416 | |
|
|
1417 | void |
1391 | LOG (int level, utf8_string msg) |
1418 | LOG (int flags, utf8_string msg) |
1392 | PROTOTYPE: $$ |
1419 | PROTOTYPE: $$ |
1393 | C_ARGS: (LogLevel)level, "%s", msg |
1420 | C_ARGS: flags, "%s", msg |
1394 | |
1421 | |
1395 | octet_string path_combine (octet_string base, octet_string path) |
1422 | octet_string path_combine (octet_string base, octet_string path) |
1396 | PROTOTYPE: $$ |
1423 | PROTOTYPE: $$ |
1397 | |
1424 | |
1398 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1425 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |