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.194 by root, Mon Apr 23 18:09:57 2007 UTC vs.
Revision 1.211 by root, Sat May 19 11:19:03 2007 UTC

1/*****************************************************************************/
2/* CrossFire, A Multiplayer game for the X Window System */
3/*****************************************************************************/
4
5/* 1/*
2 * CrossFire, A Multiplayer game
3 *
6 * This code is placed under the GNU General Public Licence (GPL) 4 * This code is placed under the GNU General Public Licence (GPL)
7 * 5 *
8 * Copyright (C) 2001-2005 by Chachkoff Yann 6 * Copyright (C) 2001-2005 by Chachkoff Yann
9 * Copyright (C) 2006,2007 by Marc Lehmann <cf@schmorp.de> 7 * Copyright (C) 2006,2007 by Marc Lehmann <cf@schmorp.de>
10 * 8 *
21 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
23 * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */ 22 */
25 23
24#include "autoconf.h"
25
26#define PLUGIN_NAME "perl" 26#define PLUGIN_NAME "perl"
27#define PLUGIN_VERSION "cfperl 0.5" 27#define PLUGIN_VERSION "cfperl 0.5"
28 28
29#define CEDES_PER_TICK 5 29#define CEDES_PER_TICK 5
30
31#if HAVE_EXECINFO_H
32# include <execinfo.h>
33#endif
30 34
31#include <plugin_common.h> 35#include <plugin_common.h>
32#include <sounds.h> 36#include <sounds.h>
33#include <cstdarg> 37#include <cstdarg>
34#include <sproto.h> 38#include <sproto.h>
80double runtime; 84double runtime;
81 85
82global gbl_ev; 86global gbl_ev;
83static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; 87static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
84static SV *sv_runtime, *sv_next_tick; 88static SV *sv_runtime, *sv_next_tick;
89
90bitset<NUM_EVENT_TYPES> ev_want_event;
91bitset<NUM_TYPES> ev_want_type;
85 92
86static HV 93static HV
87 *stash_cf, 94 *stash_cf,
88 *stash_cf_object_wrap, 95 *stash_cf_object_wrap,
89 *stash_cf_object_player_wrap, 96 *stash_cf_object_player_wrap,
111 118
112unordered_vector<attachable *> attachable::mortals; 119unordered_vector<attachable *> attachable::mortals;
113 120
114attachable::~attachable () 121attachable::~attachable ()
115{ 122{
116 flags |=0x3300;//D
117 assert (!self); 123 assert (!self);
118 assert (!cb); 124 assert (!cb);
119} 125}
120 126
121int 127int
137 sv_unmagic ((SV *)self, PERL_MAGIC_ext); 143 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
138 SvREFCNT_dec (self); 144 SvREFCNT_dec (self);
139 145
140 // self *must* be null now because thats sv_unmagic's job. 146 // self *must* be null now because thats sv_unmagic's job.
141 assert (!this->self); 147 assert (!this->self);
142 flags |= 0x80; // severed //D
143 } 148 }
144} 149}
145 150
146void 151void
147attachable::optimise () 152attachable::optimise ()
148{ 153{
149 if (self 154 if (self
150 && SvREFCNT (self) == 1 155 && SvREFCNT (self) == 1
151 && !HvTOTALKEYS (self)) 156 && !HvTOTALKEYS (self))
152 flags |= 0x40,//D
153 sever_self (); 157 sever_self ();
154} 158}
155 159
156// check wether the object really is dead 160// check wether the object really is dead
157void 161void
172 { 176 {
173 SvREFCNT_dec (cb); 177 SvREFCNT_dec (cb);
174 cb = 0; 178 cb = 0;
175 } 179 }
176 180
177 if (self)
178 sever_self ();
179
180 flags |= 0x20; //D
181 mortals.push_back (this); 181 mortals.push_back (this);
182} 182}
183 183
184void 184void
185attachable::destroy () 185attachable::destroy ()
187 if (destroyed ()) 187 if (destroyed ())
188 return; 188 return;
189 189
190 flags |= F_DESTROYED; 190 flags |= F_DESTROYED;
191 do_destroy (); 191 do_destroy ();
192 sever_self ();
192} 193}
193 194
194void 195void
195attachable::check_mortals () 196attachable::check_mortals ()
196{ 197{
201 if (i >= mortals.size ()) 202 if (i >= mortals.size ())
202 { 203 {
203 i = 0; 204 i = 0;
204 205
205 if (mortals.size () > 1000) 206 if (mortals.size () > 1000)
206 fprintf (stderr, "mortal queue size (%d) exceeds 1000.\n", (int)mortals.size ()); 207 LOG (llevInfo, "mortal queue size (%d) exceeds 1000.\n", (int)mortals.size ());
207 208
208 break; 209 break;
209 } 210 }
210 211
211 attachable *obj = mortals [i]; 212 attachable *obj = mortals [i];
212 213
213 obj->refcnt_chk (); // unborrow from perl, if necessary 214#if 0
214 215 if (obj->self)//D make this an assert later
215 //if (obj->refcnt > 0 || obj->self)
216 if (obj->refcnt || obj->self)
217 { 216 {
218//printf ("%p rc %d\n", obj, obj->refcnt_cnt ());//D 217 LOG (llevError, "check_mortals: object '%s' still has self\n", typeid (obj).name ());
218 obj->sever_self ();
219 }
220#endif
221
222 if (obj->refcnt)
223 {
219 ++i; // further delay freeing 224 ++i; // further delay freeing
220 225
221 if (!(i & 0x3ff)) 226 if (!(i & 0x3ff))
222 break; 227 break;
223 } 228 }
224 else 229 else
225 { 230 {
226 mortals.erase (i); 231 mortals.erase (i);
232 obj->sever_self ();
227 delete obj; 233 delete obj;
228 } 234 }
229 } 235 }
230} 236}
231 237
280 286
281 if (!obj->self) 287 if (!obj->self)
282 { 288 {
283 obj->self = newHV (); 289 obj->self = newHV ();
284 sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); 290 sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0);
285 obj->flags |= (obj->flags & 0xc0) << 8;
286 obj->flags &= ~0xc0;//D
287 obj->flags |= 0x10;//D
288 291
289 // now bless the object _once_ 292 // now bless the object _once_
290 return sv_bless (newRV_inc ((SV *)obj->self), stash); 293 return sv_bless (newRV_inc ((SV *)obj->self), stash);
291 } 294 }
292 else 295 else
402inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 405inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
403 406
404template<int N> 407template<int N>
405inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } 408inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
406 409
407inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); }
408inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } 410inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); }
409inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } 411inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); }
410inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } 412inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
411inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } 413inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
412 414
615 perl_construct (perl); 617 perl_construct (perl);
616 618
617 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 619 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
618 620
619 const char *argv[] = { 621 const char *argv[] = {
620 "", 622 settings.argv [0],
621 "-e" 623 "-e"
622 "use Event; use Coro;" // required for bootstrap 624 "use Event; use Coro;" // required for bootstrap
623 "cf->bootstrap;" // required for datadir :*> 625 "cf->bootstrap;" // required for datadir :*>
624 "unshift @INC, cf::datadir ();" 626 "unshift @INC, cf::datadir ();"
625 "require cf;" 627 "require cf;"
716} 718}
717 719
718void 720void
719global::gather_callbacks (AV *&callbacks, event_type event) const 721global::gather_callbacks (AV *&callbacks, event_type event) const
720{ 722{
721 ::gather_callbacks (callbacks, cb_object, event); 723 ::gather_callbacks (callbacks, cb_global, event);
722} 724}
723 725
724void 726void
725object::gather_callbacks (AV *&callbacks, event_type event) const 727object::gather_callbacks (AV *&callbacks, event_type event) const
726{ 728{
727 if (subtype && type + subtype * NUM_SUBTYPES <= AvFILLp (cb_type)) 729 if (subtype && type + subtype * NUM_TYPES <= AvFILLp (cb_type))
728 { 730 {
729 SV *registry = AvARRAY (cb_type)[type + subtype * NUM_SUBTYPES]; 731 SV *registry = AvARRAY (cb_type)[type + subtype * NUM_TYPES];
730 732
731 if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) 733 if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV)
732 ::gather_callbacks (callbacks, (AV *)SvRV (registry), event); 734 ::gather_callbacks (callbacks, (AV *)SvRV (registry), event);
733 } 735 }
734 736
770{ 772{
771 attachable::gather_callbacks (callbacks, event); 773 attachable::gather_callbacks (callbacks, event);
772 ::gather_callbacks (callbacks, cb_map, event); 774 ::gather_callbacks (callbacks, cb_map, event);
773} 775}
774 776
777void
778_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry)
779{
780 for (int event = 0; event <= AvFILLp (registry); ++event)
781 {
782 SV *cbs_ = AvARRAY (registry)[event];
783
784 // element must be list of callback entries
785 if (cbs_ && SvROK (cbs_) && SvTYPE (SvRV (cbs_)) == SVt_PVAV)
786 {
787 AV *cbs = (AV *)SvRV (cbs_);
788
789 // no callback entries, no callbacks to call
790 if (AvFILLp (cbs) >= 0)
791 set.set (event);
792 }
793 }
794}
795
796// very slow and inefficient way to recalculate the global want bitsets
797void
798_recalc_want ()
799{
800 ev_want_event.reset ();
801
802 _recalc_want (ev_want_event, cb_global);
803 _recalc_want (ev_want_event, cb_attachable);
804 _recalc_want (ev_want_event, cb_object);
805 _recalc_want (ev_want_event, cb_client);
806 _recalc_want (ev_want_event, cb_player);
807 _recalc_want (ev_want_event, cb_map);
808
809 ev_want_type.reset ();
810
811 for (int type = 0; type <= AvFILLp (cb_type); ++type)
812 {
813 SV *cbs_ = AvARRAY (cb_type)[type];
814
815 // element must be list of callback entries
816 if (cbs_ && SvROK (cbs_) && SvTYPE (SvRV (cbs_)) == SVt_PVAV)
817 {
818 AV *cbs = (AV *)SvRV (cbs_);
819
820 // no callback entries, no callbacks to call
821 if (AvFILLp (cbs) >= 0)
822 ev_want_type.set (type % NUM_TYPES);
823 }
824 }
825}
826
775bool 827bool
776attachable::invoke (event_type event, ...) 828attachable::vinvoke (event_type event, va_list &ap)
777{ 829{
778 data_type dt; 830 data_type dt;
779 va_list ap;
780
781 va_start (ap, event);
782 831
783 // callback call ordering should be: 832 // callback call ordering should be:
784 // 1. per-object callback 833 // 1. per-object callback
785 // 2. per-class object 834 // 2. per-class object
786 // 3. per-type callback 835 // 3. per-type callback
945 CALL_BEGIN (2); 994 CALL_BEGIN (2);
946 CALL_ARG (this); 995 CALL_ARG (this);
947 CALL_ARG (exit); 996 CALL_ARG (exit);
948 CALL_CALL ("cf::object::player::enter_exit", G_VOID); 997 CALL_CALL ("cf::object::player::enter_exit", G_VOID);
949 CALL_END; 998 CALL_END;
999}
1000
1001void
1002log_backtrace (const char *msg)
1003{
1004#if HAVE_BACKTRACE
1005 void *addr [20];
1006 int size = backtrace (addr, 20);
1007
1008 CALL_BEGIN (size);
1009 CALL_ARG (msg);
1010 for (int i = 0; i < size; ++i)
1011 CALL_ARG ((IV)addr [i]);
1012 CALL_CALL ("cf::_log_backtrace", G_VOID);
1013 CALL_END;
1014#endif
950} 1015}
951 1016
952///////////////////////////////////////////////////////////////////////////// 1017/////////////////////////////////////////////////////////////////////////////
953 1018
954struct EventAPI *watcher_base::GEventAPI; 1019struct EventAPI *watcher_base::GEventAPI;
1110 const char *name; 1175 const char *name;
1111 IV iv; 1176 IV iv;
1112 } *civ, const_iv[] = { 1177 } *civ, const_iv[] = {
1113# define const_iv(name) { # name, (IV)name }, 1178# define const_iv(name) { # name, (IV)name },
1114 const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) 1179 const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster)
1180 const_iv (logBacktrace)
1115 1181
1116 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1182 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1117 1183
1118 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1184 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1119 1185
1120 const_iv (MAX_TIME) 1186 const_iv (MAX_TIME)
1187
1188 const_iv (NUM_BODY_LOCATIONS)
1189 const_iv (body_range) const_iv (body_shield) const_iv (body_combat)
1190 const_iv (body_arm) const_iv (body_torso) const_iv (body_head)
1191 const_iv (body_neck) const_iv (body_skill) const_iv (body_finger)
1192 const_iv (body_shoulder) const_iv (body_foot) const_iv (body_hand)
1193 const_iv (body_wrist) const_iv (body_waist)
1121 1194
1122 const_iv (PLAYER) const_iv (TRANSPORT) const_iv (ROD) const_iv (TREASURE) 1195 const_iv (PLAYER) const_iv (TRANSPORT) const_iv (ROD) const_iv (TREASURE)
1123 const_iv (POTION) const_iv (FOOD) const_iv (POISON) const_iv (BOOK) 1196 const_iv (POTION) const_iv (FOOD) const_iv (POISON) const_iv (BOOK)
1124 const_iv (CLOCK) const_iv (ARROW) const_iv (BOW) const_iv (WEAPON) 1197 const_iv (CLOCK) const_iv (ARROW) const_iv (BOW) const_iv (WEAPON)
1125 const_iv (ARMOUR) const_iv (PEDESTAL) const_iv (ALTAR) const_iv (LOCKED_DOOR) 1198 const_iv (ARMOUR) const_iv (PEDESTAL) const_iv (ALTAR) const_iv (LOCKED_DOOR)
1146 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) 1219 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL)
1147 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) 1220 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE)
1148 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) 1221 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE)
1149 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) 1222 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER)
1150 1223
1151 const_iv (NUM_SUBTYPES) 1224 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES)
1152 1225
1153 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) 1226 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE)
1154 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) 1227 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM)
1155 1228
1156 const_iv (AT_PHYSICAL) const_iv (AT_MAGIC) const_iv (AT_FIRE) const_iv (AT_ELECTRICITY) 1229 const_iv (AT_PHYSICAL) const_iv (AT_MAGIC) const_iv (AT_FIRE) const_iv (AT_ELECTRICITY)
1164 const_iv (WEAP_HIT) const_iv (WEAP_SLASH) const_iv (WEAP_PIERCE) const_iv (WEAP_CLEAVE) 1237 const_iv (WEAP_HIT) const_iv (WEAP_SLASH) const_iv (WEAP_PIERCE) const_iv (WEAP_CLEAVE)
1165 const_iv (WEAP_SLICE) const_iv (WEAP_STAB) const_iv (WEAP_WHIP) const_iv (WEAP_CRUSH) 1238 const_iv (WEAP_SLICE) const_iv (WEAP_STAB) const_iv (WEAP_WHIP) const_iv (WEAP_CRUSH)
1166 const_iv (WEAP_BLUD) 1239 const_iv (WEAP_BLUD)
1167 1240
1168 const_iv (FLAG_ALIVE) const_iv (FLAG_WIZ) const_iv (FLAG_REMOVED) const_iv (FLAG_FREED) 1241 const_iv (FLAG_ALIVE) const_iv (FLAG_WIZ) const_iv (FLAG_REMOVED) const_iv (FLAG_FREED)
1169 const_iv (FLAG_WAS_WIZ) const_iv (FLAG_APPLIED) const_iv (FLAG_UNPAID) const_iv (FLAG_USE_SHIELD) 1242 const_iv (FLAG_APPLIED) const_iv (FLAG_UNPAID) const_iv (FLAG_USE_SHIELD)
1170 const_iv (FLAG_NO_PICK) const_iv (FLAG_ANIMATE) const_iv (FLAG_MONSTER) const_iv (FLAG_FRIENDLY) 1243 const_iv (FLAG_NO_PICK) const_iv (FLAG_ANIMATE) const_iv (FLAG_MONSTER) const_iv (FLAG_FRIENDLY)
1171 const_iv (FLAG_GENERATOR) const_iv (FLAG_IS_THROWN) const_iv (FLAG_AUTO_APPLY) const_iv (FLAG_PLAYER_SOLD) 1244 const_iv (FLAG_GENERATOR) const_iv (FLAG_IS_THROWN) const_iv (FLAG_AUTO_APPLY) const_iv (FLAG_PLAYER_SOLD)
1172 const_iv (FLAG_SEE_INVISIBLE) const_iv (FLAG_CAN_ROLL) const_iv (FLAG_OVERLAY_FLOOR) const_iv (FLAG_IS_TURNABLE) 1245 const_iv (FLAG_SEE_INVISIBLE) const_iv (FLAG_CAN_ROLL) const_iv (FLAG_OVERLAY_FLOOR) const_iv (FLAG_IS_TURNABLE)
1173 const_iv (FLAG_IS_USED_UP) const_iv (FLAG_IDENTIFIED) const_iv (FLAG_REFLECTING) const_iv (FLAG_CHANGING) 1246 const_iv (FLAG_IS_USED_UP) const_iv (FLAG_IDENTIFIED) const_iv (FLAG_REFLECTING) const_iv (FLAG_CHANGING)
1174 const_iv (FLAG_SPLITTING) const_iv (FLAG_HITBACK) const_iv (FLAG_STARTEQUIP) const_iv (FLAG_BLOCKSVIEW) 1247 const_iv (FLAG_SPLITTING) const_iv (FLAG_HITBACK) const_iv (FLAG_STARTEQUIP) const_iv (FLAG_BLOCKSVIEW)
1266 1339
1267 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) 1340 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT)
1268 1341
1269 const_iv (ST_DEAD) const_iv (ST_SETUP) const_iv (ST_PLAYING) const_iv (ST_CUSTOM) 1342 const_iv (ST_DEAD) const_iv (ST_SETUP) const_iv (ST_PLAYING) const_iv (ST_CUSTOM)
1270 1343
1271 const_iv (ST_CHANGE_CLASS)
1272
1273 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) 1344 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES)
1274 1345
1275 // random map generator 1346 // random map generator
1276 const_iv (LAYOUT_NONE) const_iv (LAYOUT_ONION) const_iv (LAYOUT_MAZE) const_iv (LAYOUT_SPIRAL) 1347 const_iv (LAYOUT_NONE) const_iv (LAYOUT_ONION) const_iv (LAYOUT_MAZE) const_iv (LAYOUT_SPIRAL)
1277 const_iv (LAYOUT_ROGUELIKE) const_iv (LAYOUT_SNAKE) const_iv (LAYOUT_SQUARE_SPIRAL) 1348 const_iv (LAYOUT_ROGUELIKE) const_iv (LAYOUT_SNAKE) const_iv (LAYOUT_SQUARE_SPIRAL)
1280 const_iv (RMOPT_BOTTOM_C) const_iv (RMOPT_BOTTOM_R) const_iv (RMOPT_IRR_SPACE) 1351 const_iv (RMOPT_BOTTOM_C) const_iv (RMOPT_BOTTOM_R) const_iv (RMOPT_IRR_SPACE)
1281 const_iv (RMOPT_WALL_OFF) const_iv (RMOPT_WALLS_ONLY) const_iv (RMOPT_NO_DOORS) 1352 const_iv (RMOPT_WALL_OFF) const_iv (RMOPT_WALLS_ONLY) const_iv (RMOPT_NO_DOORS)
1282 1353
1283 const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) 1354 const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X)
1284 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) 1355 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY)
1356
1357 const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP)
1358 const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV)
1359 const_iv (GT_MINIMAL)
1285 }; 1360 };
1286 1361
1287 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1362 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1288 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); 1363 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv));
1289 1364
1310 } 1385 }
1311} 1386}
1312 1387
1313void _connect_to_perl () 1388void _connect_to_perl ()
1314 1389
1390void _recalc_want ()
1391
1315void _global_reattach () 1392void _global_reattach ()
1316 CODE: 1393 CODE:
1317{ 1394{
1318 // reattach to all attachable objects in the game. 1395 // reattach to all attachable objects in the game.
1319 for_all_clients (ns) 1396 for_all_clients (ns)
1383 default: croak ("cf::rndm requires none, one or two parameters."); break; 1460 default: croak ("cf::rndm requires none, one or two parameters."); break;
1384 } 1461 }
1385 OUTPUT: 1462 OUTPUT:
1386 RETVAL 1463 RETVAL
1387 1464
1465NV clamp (NV value, NV min_value, NV max_value)
1466 CODE:
1467 RETVAL = clamp (value, min_value, max_value);
1468 OUTPUT:
1469 RETVAL
1470
1471NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out)
1472 CODE:
1473 RETVAL = lerp (value, min_in, max_in, min_out, max_out);
1474 OUTPUT:
1475 RETVAL
1476
1477void cede_to_tick ()
1478 CODE:
1479 coroapi::cede_to_tick ();
1480
1388void server_tick () 1481void server_tick ()
1389 CODE: 1482 CODE:
1390 runtime = SvNVx (sv_runtime); 1483 runtime = SvNVx (sv_runtime);
1391 server_tick (); 1484 server_tick ();
1392 1485
1393void 1486void
1487log_backtrace (utf8_string msg)
1488
1489void
1394LOG (int level, utf8_string msg) 1490LOG (int flags, utf8_string msg)
1395 PROTOTYPE: $$ 1491 PROTOTYPE: $$
1396 C_ARGS: (LogLevel)level, "%s", msg 1492 C_ARGS: flags, "%s", msg
1397 1493
1398octet_string path_combine (octet_string base, octet_string path) 1494octet_string path_combine (octet_string base, octet_string path)
1399 PROTOTYPE: $$ 1495 PROTOTYPE: $$
1400 1496
1401octet_string path_combine_and_normalize (octet_string base, octet_string path) 1497octet_string path_combine_and_normalize (octet_string base, octet_string path)
1438 } 1534 }
1439 OUTPUT: RETVAL 1535 OUTPUT: RETVAL
1440 1536
1441void abort () 1537void abort ()
1442 1538
1539void reset_signals ()
1540
1443void fork_abort (octet_string cause = "cf::fork_abort") 1541void fork_abort (octet_string cause = "cf::fork_abort")
1444 1542
1445void cleanup (octet_string cause, bool make_core = false) 1543void cleanup (octet_string cause, bool make_core = false)
1446 1544
1447void emergency_save () 1545void emergency_save ()
1581object *actives (U32 index) 1679object *actives (U32 index)
1582 CODE: 1680 CODE:
1583 RETVAL = index < actives.size () ? actives [index] : 0; 1681 RETVAL = index < actives.size () ? actives [index] : 0;
1584 OUTPUT: RETVAL 1682 OUTPUT: RETVAL
1585 1683
1684const char *slot_save_name (U32 slot)
1685 ALIAS:
1686 slot_use_name = 1
1687 slot_nonuse_name = 2
1688 CODE:
1689{
1690 if (slot >= NUM_BODY_LOCATIONS)
1691 croak ("body slot index out of range");
1692
1693 switch (ix)
1694 {
1695 case 0: RETVAL = body_locations[slot].save_name; break;
1696 case 1: RETVAL = body_locations[slot].use_name; break;
1697 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1698 }
1699}
1700 OUTPUT:
1701 RETVAL
1702
1586# missing properties 1703# missing properties
1587 1704
1588object *head (object *op) 1705object *head (object *op)
1589 PROTOTYPE: $ 1706 PROTOTYPE: $
1590 CODE: 1707 CODE:
1615int 1732int
1616num_animations (object *op) 1733num_animations (object *op)
1617 CODE: 1734 CODE:
1618 RETVAL = NUM_ANIMATIONS (op); 1735 RETVAL = NUM_ANIMATIONS (op);
1619 OUTPUT: RETVAL 1736 OUTPUT: RETVAL
1737
1738int slot_info (object *op, UV slot, int value = 0)
1739 ALIAS:
1740 slot_used = 1
1741 CODE:
1742{
1743 if (slot >= NUM_BODY_LOCATIONS)
1744 croak ("body slot index out of range");
1745
1746 RETVAL = ix ? op->slot[slot].used : op->slot[slot].info;
1747
1748 if (items > 2)
1749 if (ix)
1750 op->slot[slot].used = value;
1751 else
1752 op->slot[slot].info = value;
1753}
1754 OUTPUT:
1755 RETVAL
1620 1756
1621object *find_best_object_match (object *op, utf8_string match) 1757object *find_best_object_match (object *op, utf8_string match)
1622 1758
1623object *find_marked_object (object *op) 1759object *find_marked_object (object *op)
1624 1760
1805void check_score (object *op) 1941void check_score (object *op)
1806 1942
1807void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE) 1943void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE)
1808 CODE: 1944 CODE:
1809 new_draw_info (flags, 0, op, txt); 1945 new_draw_info (flags, 0, op, txt);
1810
1811object *cf_player_send_inventory (object *op)
1812
1813octet_string cf_player_get_ip (object *op)
1814 ALIAS: ip = 0
1815
1816object *cf_player_get_marked_item (object *op)
1817 ALIAS: marked_item = 0
1818
1819void cf_player_set_marked_item (object *op, object *ob)
1820
1821partylist *cf_player_get_party (object *op)
1822 ALIAS: party = 0
1823
1824void cf_player_set_party (object *op, partylist *party)
1825 1946
1826void kill_player (object *op) 1947void kill_player (object *op)
1827 1948
1828void esrv_update_item (object *op, int what, object *item) 1949void esrv_update_item (object *op, int what, object *item)
1829 C_ARGS: what, op, item 1950 C_ARGS: what, op, item
1973 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2094 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
1974 { 2095 {
1975 object *ob = get_archetype (SvPVutf8_nolen (*elem)); 2096 object *ob = get_archetype (SvPVutf8_nolen (*elem));
1976 ob->flag [FLAG_NO_MAP_SAVE] = true; 2097 ob->flag [FLAG_NO_MAP_SAVE] = true;
1977 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2098 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2099
2100 if (ob->randomitems)
2101 {
2102 if (!ob->above)
2103 {
2104 ob->create_treasure (ob->randomitems);
2105
2106 for (object *op = ob->above; op; op = op->above)
2107 op->flag [FLAG_NO_MAP_SAVE] = true;
2108 }
2109
2110 ob->randomitems = 0;
2111 }
1978 } 2112 }
1979 } 2113 }
1980 } 2114 }
1981 2115
1982 skip_space: ; 2116 skip_space: ;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines