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.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,
180 if (destroyed ()) 187 if (destroyed ())
181 return; 188 return;
182 189
183 flags |= F_DESTROYED; 190 flags |= F_DESTROYED;
184 do_destroy (); 191 do_destroy ();
192 sever_self ();
185} 193}
186 194
187void 195void
188attachable::check_mortals () 196attachable::check_mortals ()
189{ 197{
209 LOG (llevError, "check_mortals: object '%s' still has self\n", typeid (obj).name ()); 217 LOG (llevError, "check_mortals: object '%s' still has self\n", typeid (obj).name ());
210 obj->sever_self (); 218 obj->sever_self ();
211 } 219 }
212#endif 220#endif
213 221
214 if (obj->refcnt_cnt ()) 222 if (obj->refcnt)
215 { 223 {
216 ++i; // further delay freeing 224 ++i; // further delay freeing
217 225
218 if (!(i & 0x3ff)) 226 if (!(i & 0x3ff))
219 break; 227 break;
397inline 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; }
398 406
399template<int N> 407template<int N>
400inline 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)); }
401 409
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); } 410inline 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); } 411inline 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); } 412inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
406inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } 413inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
407 414
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;"
711} 718}
712 719
713void 720void
714global::gather_callbacks (AV *&callbacks, event_type event) const 721global::gather_callbacks (AV *&callbacks, event_type event) const
715{ 722{
716 ::gather_callbacks (callbacks, cb_object, event); 723 ::gather_callbacks (callbacks, cb_global, event);
717} 724}
718 725
719void 726void
720object::gather_callbacks (AV *&callbacks, event_type event) const 727object::gather_callbacks (AV *&callbacks, event_type event) const
721{ 728{
722 if (subtype && type + subtype * NUM_SUBTYPES <= AvFILLp (cb_type)) 729 if (subtype && type + subtype * NUM_TYPES <= AvFILLp (cb_type))
723 { 730 {
724 SV *registry = AvARRAY (cb_type)[type + subtype * NUM_SUBTYPES]; 731 SV *registry = AvARRAY (cb_type)[type + subtype * NUM_TYPES];
725 732
726 if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) 733 if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV)
727 ::gather_callbacks (callbacks, (AV *)SvRV (registry), event); 734 ::gather_callbacks (callbacks, (AV *)SvRV (registry), event);
728 } 735 }
729 736
765{ 772{
766 attachable::gather_callbacks (callbacks, event); 773 attachable::gather_callbacks (callbacks, event);
767 ::gather_callbacks (callbacks, cb_map, event); 774 ::gather_callbacks (callbacks, cb_map, event);
768} 775}
769 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
770bool 827bool
771attachable::invoke (event_type event, ...) 828attachable::vinvoke (event_type event, va_list &ap)
772{ 829{
773 data_type dt; 830 data_type dt;
774 va_list ap;
775
776 va_start (ap, event);
777 831
778 // callback call ordering should be: 832 // callback call ordering should be:
779 // 1. per-object callback 833 // 1. per-object callback
780 // 2. per-class object 834 // 2. per-class object
781 // 3. per-type callback 835 // 3. per-type callback
940 CALL_BEGIN (2); 994 CALL_BEGIN (2);
941 CALL_ARG (this); 995 CALL_ARG (this);
942 CALL_ARG (exit); 996 CALL_ARG (exit);
943 CALL_CALL ("cf::object::player::enter_exit", G_VOID); 997 CALL_CALL ("cf::object::player::enter_exit", G_VOID);
944 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
945} 1015}
946 1016
947///////////////////////////////////////////////////////////////////////////// 1017/////////////////////////////////////////////////////////////////////////////
948 1018
949struct EventAPI *watcher_base::GEventAPI; 1019struct EventAPI *watcher_base::GEventAPI;
1105 const char *name; 1175 const char *name;
1106 IV iv; 1176 IV iv;
1107 } *civ, const_iv[] = { 1177 } *civ, const_iv[] = {
1108# define const_iv(name) { # name, (IV)name }, 1178# define const_iv(name) { # name, (IV)name },
1109 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)
1110 1181
1111 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1182 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1112 1183
1113 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1184 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1114 1185
1115 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)
1116 1194
1117 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)
1118 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)
1119 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)
1120 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)
1141 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)
1142 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)
1143 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)
1144 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)
1145 1223
1146 const_iv (NUM_SUBTYPES) 1224 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES)
1147 1225
1148 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) 1226 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE)
1149 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)
1150 1228
1151 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)
1159 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)
1160 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)
1161 const_iv (WEAP_BLUD) 1239 const_iv (WEAP_BLUD)
1162 1240
1163 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)
1164 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)
1165 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)
1166 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)
1167 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)
1168 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)
1169 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)
1307 } 1385 }
1308} 1386}
1309 1387
1310void _connect_to_perl () 1388void _connect_to_perl ()
1311 1389
1390void _recalc_want ()
1391
1312void _global_reattach () 1392void _global_reattach ()
1313 CODE: 1393 CODE:
1314{ 1394{
1315 // reattach to all attachable objects in the game. 1395 // reattach to all attachable objects in the game.
1316 for_all_clients (ns) 1396 for_all_clients (ns)
1380 default: croak ("cf::rndm requires none, one or two parameters."); break; 1460 default: croak ("cf::rndm requires none, one or two parameters."); break;
1381 } 1461 }
1382 OUTPUT: 1462 OUTPUT:
1383 RETVAL 1463 RETVAL
1384 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
1385void server_tick () 1481void server_tick ()
1386 CODE: 1482 CODE:
1387 runtime = SvNVx (sv_runtime); 1483 runtime = SvNVx (sv_runtime);
1388 server_tick (); 1484 server_tick ();
1389 1485
1390void 1486void
1487log_backtrace (utf8_string msg)
1488
1489void
1391LOG (int level, utf8_string msg) 1490LOG (int flags, utf8_string msg)
1392 PROTOTYPE: $$ 1491 PROTOTYPE: $$
1393 C_ARGS: (LogLevel)level, "%s", msg 1492 C_ARGS: flags, "%s", msg
1394 1493
1395octet_string path_combine (octet_string base, octet_string path) 1494octet_string path_combine (octet_string base, octet_string path)
1396 PROTOTYPE: $$ 1495 PROTOTYPE: $$
1397 1496
1398octet_string path_combine_and_normalize (octet_string base, octet_string path) 1497octet_string path_combine_and_normalize (octet_string base, octet_string path)
1435 } 1534 }
1436 OUTPUT: RETVAL 1535 OUTPUT: RETVAL
1437 1536
1438void abort () 1537void abort ()
1439 1538
1539void reset_signals ()
1540
1440void fork_abort (octet_string cause = "cf::fork_abort") 1541void fork_abort (octet_string cause = "cf::fork_abort")
1441 1542
1442void cleanup (octet_string cause, bool make_core = false) 1543void cleanup (octet_string cause, bool make_core = false)
1443 1544
1444void emergency_save () 1545void emergency_save ()
1578object *actives (U32 index) 1679object *actives (U32 index)
1579 CODE: 1680 CODE:
1580 RETVAL = index < actives.size () ? actives [index] : 0; 1681 RETVAL = index < actives.size () ? actives [index] : 0;
1581 OUTPUT: RETVAL 1682 OUTPUT: RETVAL
1582 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
1583# missing properties 1703# missing properties
1584 1704
1585object *head (object *op) 1705object *head (object *op)
1586 PROTOTYPE: $ 1706 PROTOTYPE: $
1587 CODE: 1707 CODE:
1612int 1732int
1613num_animations (object *op) 1733num_animations (object *op)
1614 CODE: 1734 CODE:
1615 RETVAL = NUM_ANIMATIONS (op); 1735 RETVAL = NUM_ANIMATIONS (op);
1616 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
1617 1756
1618object *find_best_object_match (object *op, utf8_string match) 1757object *find_best_object_match (object *op, utf8_string match)
1619 1758
1620object *find_marked_object (object *op) 1759object *find_marked_object (object *op)
1621 1760
1802void check_score (object *op) 1941void check_score (object *op)
1803 1942
1804void 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)
1805 CODE: 1944 CODE:
1806 new_draw_info (flags, 0, op, txt); 1945 new_draw_info (flags, 0, op, txt);
1807
1808object *cf_player_send_inventory (object *op)
1809
1810octet_string cf_player_get_ip (object *op)
1811 ALIAS: ip = 0
1812
1813object *cf_player_get_marked_item (object *op)
1814 ALIAS: marked_item = 0
1815
1816void cf_player_set_marked_item (object *op, object *ob)
1817
1818partylist *cf_player_get_party (object *op)
1819 ALIAS: party = 0
1820
1821void cf_player_set_party (object *op, partylist *party)
1822 1946
1823void kill_player (object *op) 1947void kill_player (object *op)
1824 1948
1825void esrv_update_item (object *op, int what, object *item) 1949void esrv_update_item (object *op, int what, object *item)
1826 C_ARGS: what, op, item 1950 C_ARGS: what, op, item
1970 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2094 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
1971 { 2095 {
1972 object *ob = get_archetype (SvPVutf8_nolen (*elem)); 2096 object *ob = get_archetype (SvPVutf8_nolen (*elem));
1973 ob->flag [FLAG_NO_MAP_SAVE] = true; 2097 ob->flag [FLAG_NO_MAP_SAVE] = true;
1974 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 }
1975 } 2112 }
1976 } 2113 }
1977 } 2114 }
1978 2115
1979 skip_space: ; 2116 skip_space: ;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines