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 (©) 2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
12 | * option) any later version. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * GNU General Public License for more details. |
17 | * |
18 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
21 | * <http://www.gnu.org/licenses/>. |
21 | * |
22 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
24 | */ |
24 | |
25 | |
25 | #ifndef OBJECT_H |
26 | #ifndef OBJECT_H |
26 | #define OBJECT_H |
27 | #define OBJECT_H |
… | |
… | |
33 | typedef int tag_t; |
34 | typedef int tag_t; |
34 | |
35 | |
35 | // also see common/item.C |
36 | // also see common/item.C |
36 | enum |
37 | enum |
37 | { |
38 | { |
38 | body_skill, |
39 | # define def(name, use, nonuse) body_ ## name, |
39 | body_combat, |
40 | # include "slotinc.h" |
40 | body_range, |
41 | # undef def |
41 | body_shield, |
|
|
42 | body_arm, |
|
|
43 | body_torso, |
|
|
44 | body_head, |
|
|
45 | body_neck, |
|
|
46 | body_finger, |
|
|
47 | body_shoulder, |
|
|
48 | body_foot, |
|
|
49 | body_hand, |
|
|
50 | body_wrist, |
|
|
51 | body_waist, |
|
|
52 | NUM_BODY_LOCATIONS |
42 | NUM_BODY_LOCATIONS |
53 | }; |
43 | }; |
54 | |
44 | |
55 | /* See common/item.c */ |
45 | /* See common/item.c */ |
56 | |
46 | |
57 | typedef struct Body_Locations |
47 | struct Body_Locations |
58 | { |
48 | { |
|
|
49 | const char *name; /* Short name/identifier */ |
59 | keyword save_name; /* Name used to load/save it to disk */ |
50 | keyword kw; /* Name used to load/save it to disk */ |
60 | const char *use_name; /* Name used when describing an item we can use */ |
51 | const char *use_name; /* Name used when describing an item we can use */ |
61 | const char *nonuse_name; /* Name to describe objects we can't use */ |
52 | const char *nonuse_name; /* Name to describe objects we can't use */ |
62 | } Body_Locations; |
53 | }; |
63 | |
54 | |
64 | extern Body_Locations body_locations[NUM_BODY_LOCATIONS]; |
55 | extern Body_Locations body_locations[NUM_BODY_LOCATIONS]; |
65 | |
56 | |
66 | // for each set of directions (1 == up, 2 == right, 4 == down, 8 == left) |
57 | // for each set of directions (1 == up, 2 == right, 4 == down, 8 == left) |
67 | // contaisn the wall suffix (0, 1_3, 1_4 and so on). |
58 | // contains the wall suffix (0, 1_3, 1_4 and so on). |
68 | extern const char *wall_suffix[16]; |
59 | extern const char *wall_suffix[16]; |
69 | |
60 | |
70 | #define NUM_COINS 4 /* number of coin types */ |
61 | #define NUM_COINS 4 /* number of coin types */ |
71 | extern const char *const coins[NUM_COINS + 1]; |
62 | extern const char *const coins[NUM_COINS + 1]; |
72 | |
63 | |
… | |
… | |
83 | * accessing the list directly. |
74 | * accessing the list directly. |
84 | * Exception is if you want to walk this list for some reason. |
75 | * Exception is if you want to walk this list for some reason. |
85 | */ |
76 | */ |
86 | struct key_value : slice_allocated |
77 | struct key_value : slice_allocated |
87 | { |
78 | { |
88 | key_value *next; |
79 | key_value *next; // must be first element |
89 | shstr key, value; |
80 | shstr key, value; |
|
|
81 | }; |
|
|
82 | |
|
|
83 | // "crossfires version of a perl hash." |
|
|
84 | struct key_values |
|
|
85 | { |
|
|
86 | key_value *first; // must be first element |
|
|
87 | |
|
|
88 | bool empty() const |
|
|
89 | { |
|
|
90 | return !first; |
|
|
91 | } |
|
|
92 | |
|
|
93 | void clear (); |
|
|
94 | shstr_tmp get (shstr_tmp key) const; |
|
|
95 | void del (shstr_tmp key); |
|
|
96 | void set (shstr_tmp key, shstr_tmp value); |
|
|
97 | |
|
|
98 | void add (shstr_tmp key, shstr_tmp value); // liek set, but doesn't check for duplicates |
|
|
99 | void reverse (); // reverses the ordering, to be used after loading an object |
|
|
100 | key_values &operator =(const key_values &kv); |
|
|
101 | |
|
|
102 | // custom extra fields management |
|
|
103 | struct access_proxy |
|
|
104 | { |
|
|
105 | key_values &kv; |
|
|
106 | shstr_tmp key; |
|
|
107 | |
|
|
108 | access_proxy (key_values &kv, shstr_tmp key) |
|
|
109 | : kv (kv), key (key) |
|
|
110 | { |
|
|
111 | } |
|
|
112 | |
|
|
113 | const access_proxy &operator =(shstr_tmp value) const |
|
|
114 | { |
|
|
115 | kv.set (key, value); |
|
|
116 | return *this; |
|
|
117 | } |
|
|
118 | |
|
|
119 | operator const shstr_tmp () const { return kv.get (key); } |
|
|
120 | operator const char *() const { return kv.get (key); } |
|
|
121 | |
|
|
122 | private: |
|
|
123 | void operator =(int); |
|
|
124 | }; |
|
|
125 | |
|
|
126 | const access_proxy operator [](shstr_tmp key) |
|
|
127 | { |
|
|
128 | return access_proxy (*this, key); |
|
|
129 | } |
90 | }; |
130 | }; |
91 | |
131 | |
92 | //-GPL |
132 | //-GPL |
93 | |
133 | |
94 | struct UUID |
134 | struct UUID |
… | |
… | |
140 | { /* Used to link together several object links */ |
180 | { /* Used to link together several object links */ |
141 | struct oblnk *link; |
181 | struct oblnk *link; |
142 | struct oblinkpt *next; |
182 | struct oblinkpt *next; |
143 | shstr id; /* Used as connected value in buttons/gates */ |
183 | shstr id; /* Used as connected value in buttons/gates */ |
144 | } oblinkpt; |
184 | } oblinkpt; |
|
|
185 | |
|
|
186 | // temporary hack to find the culprit who corrupts face numbers. maybe. hopefully. |
|
|
187 | struct faceidx_debug |
|
|
188 | { |
|
|
189 | faceidx x; |
|
|
190 | |
|
|
191 | operator faceidx () const |
|
|
192 | { |
|
|
193 | return x; |
|
|
194 | } |
|
|
195 | |
|
|
196 | faceidx operator =(faceidx i) |
|
|
197 | { |
|
|
198 | if (ecb_expect_false (i >= faces.size ())) |
|
|
199 | { |
|
|
200 | fork_abort ("illegal faceidx assignment"); |
|
|
201 | i = blank_face; |
|
|
202 | } |
|
|
203 | |
|
|
204 | return x = i; |
|
|
205 | } |
|
|
206 | }; |
|
|
207 | |
|
|
208 | #if CFPERL |
|
|
209 | static inline void sv_to (SV *sv, faceidx_debug &v) { v = SvIV (sv); } |
|
|
210 | #endif |
145 | |
211 | |
146 | INTERFACE_CLASS (object) |
212 | INTERFACE_CLASS (object) |
147 | // these are being copied |
213 | // these are being copied |
148 | struct object_copy : attachable |
214 | struct object_copy : attachable |
149 | { |
215 | { |
… | |
… | |
213 | sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ |
279 | sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ |
214 | uint8 ACC (RW, weapontype); /* type of weapon */ |
280 | uint8 ACC (RW, weapontype); /* type of weapon */ |
215 | |
281 | |
216 | body_slot slot [NUM_BODY_LOCATIONS]; |
282 | body_slot slot [NUM_BODY_LOCATIONS]; |
217 | |
283 | |
218 | faceidx ACC (RW, face); /* the graphical face */ |
284 | faceidx_debug ACC (RW, face); /* the graphical face */ |
219 | |
285 | |
220 | faceidx ACC (RW, sound); /* the sound face */ |
286 | faceidx ACC (RW, sound); /* the sound face */ |
221 | faceidx ACC (RW, sound_destroy); /* played on destroy */ |
287 | faceidx ACC (RW, sound_destroy); /* played on destroy */ |
222 | |
288 | |
223 | sint32 ACC (RW, weight); /* Attributes of the object */ |
289 | sint32 ACC (RW, weight); /* Attributes of the object */ |
… | |
… | |
255 | |
321 | |
256 | // 8 free bits |
322 | // 8 free bits |
257 | |
323 | |
258 | //float ACC (RW, expmul) = 1.0; /* needed experience = (calc_exp*expmul) - means some */ |
324 | //float ACC (RW, expmul) = 1.0; /* needed experience = (calc_exp*expmul) - means some */ |
259 | // /* races/classes can need less/more exp to gain levels */ |
325 | // /* races/classes can need less/more exp to gain levels */ |
260 | static const float expmul = 1.0;//D |
326 | constexpr static const float expmul = 1.0;//D |
261 | float ACC (RW, move_slow_penalty); /* How much this slows down the object */ |
327 | float ACC (RW, move_slow_penalty); /* How much this slows down the object */ |
262 | |
328 | |
263 | /* Following are values used by any object */ |
329 | /* Following are values used by any object */ |
264 | /* this objects turns into or what this object creates */ |
330 | /* this objects turns into or what this object creates */ |
265 | treasurelist *ACC (RW, randomitems); /* Items to be generated */ |
331 | treasurelist *ACC (RW, randomitems); /* Items to be generated */ |
… | |
… | |
332 | object *ACC (RW, env); /* Pointer to the object which is the environment. |
398 | object *ACC (RW, env); /* Pointer to the object which is the environment. |
333 | * This is typically the container that the object is in. |
399 | * This is typically the container that the object is in. |
334 | */ |
400 | */ |
335 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
401 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
336 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
402 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
337 | key_value *key_values; /* Fields not explictly known by the loader. */ |
|
|
338 | |
403 | |
339 | MTH void set_flag (int flagnum) |
404 | MTH void set_flag (int flagnum) |
340 | { |
405 | { |
341 | flag [flagnum] = true; |
406 | flag [flagnum] = true; |
342 | } |
407 | } |
… | |
… | |
344 | MTH void clr_flag (int flagnum) |
409 | MTH void clr_flag (int flagnum) |
345 | { |
410 | { |
346 | flag [flagnum] = false; |
411 | flag [flagnum] = false; |
347 | } |
412 | } |
348 | |
413 | |
349 | // privates / perl |
414 | // extra key value pairs |
350 | shstr_tmp kv_get (shstr_tmp key) const; |
415 | key_values kv; |
351 | void kv_del (shstr_tmp key); |
|
|
352 | void kv_set (shstr_tmp key, shstr_tmp value); |
|
|
353 | |
416 | |
354 | //-GPL |
417 | //-GPL |
355 | |
|
|
356 | // custom extra fields management |
|
|
357 | struct key_value_access_proxy |
|
|
358 | { |
|
|
359 | object &ob; |
|
|
360 | shstr_tmp key; |
|
|
361 | |
|
|
362 | key_value_access_proxy (object &ob, shstr_tmp key) |
|
|
363 | : ob (ob), key (key) |
|
|
364 | { |
|
|
365 | } |
|
|
366 | |
|
|
367 | const key_value_access_proxy &operator =(shstr_tmp value) const |
|
|
368 | { |
|
|
369 | ob.kv_set (key, value); |
|
|
370 | return *this; |
|
|
371 | } |
|
|
372 | |
|
|
373 | operator const shstr_tmp () const { return ob.kv_get (key); } |
|
|
374 | operator const char *() const { return ob.kv_get (key); } |
|
|
375 | |
|
|
376 | private: |
|
|
377 | void operator =(int); |
|
|
378 | }; |
|
|
379 | |
|
|
380 | // operator [] is too annoying to use |
|
|
381 | const key_value_access_proxy kv (shstr_tmp key) |
|
|
382 | { |
|
|
383 | return key_value_access_proxy (*this, key); |
|
|
384 | } |
|
|
385 | |
418 | |
386 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
419 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
387 | MTH void post_load_check (); // do some adjustments after parsing |
420 | MTH void post_load_check (); // do some adjustments after parsing |
388 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
421 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
389 | bool write (object_freezer &f); |
422 | bool write (object_freezer &f); |
… | |
… | |
429 | // object op is trying to move in direction dir. |
462 | // object op is trying to move in direction dir. |
430 | // originator is typically the same as op, but |
463 | // originator is typically the same as op, but |
431 | // can be different if originator is causing op to |
464 | // can be different if originator is causing op to |
432 | // move (originator is pushing op) |
465 | // move (originator is pushing op) |
433 | // returns 0 if the object is not able to move to the |
466 | // returns 0 if the object is not able to move to the |
434 | // desired space, 1 otherwise (in which case we also |
467 | // desired space, 1 otherwise (in which case we also |
435 | // move the object accordingly. This function is |
468 | // move the object accordingly. This function is |
436 | // very similiar to move_object. |
469 | // very similiar to move_object. |
437 | int move (int dir, object *originator); |
470 | int move (int dir, object *originator); |
438 | |
471 | |
439 | int move (int dir) |
472 | int move (int dir) |
… | |
… | |
452 | return op1->value == op2->value |
485 | return op1->value == op2->value |
453 | && op1->name == op2->name |
486 | && op1->name == op2->name |
454 | && can_merge_slow (op1, op2); |
487 | && can_merge_slow (op1, op2); |
455 | } |
488 | } |
456 | |
489 | |
457 | MTH void set_owner (object *owner); |
490 | MTH void set_owner (object_ornull *owner); |
458 | MTH void set_speed (float speed); |
491 | MTH void set_speed (float speed); |
459 | MTH void set_glow_radius (sint8 rad); |
492 | MTH void set_glow_radius (sint8 rad); |
460 | |
493 | |
461 | MTH void open_container (object *new_container); |
494 | MTH void open_container (object *new_container); |
462 | MTH void close_container () |
495 | MTH void close_container () |
… | |
… | |
475 | // strangely enough, using ?: here causes code to inflate |
508 | // strangely enough, using ?: here causes code to inflate |
476 | return type == CONTAINER |
509 | return type == CONTAINER |
477 | && ((env && env->container_ () == this) |
510 | && ((env && env->container_ () == this) |
478 | || (!env && flag [FLAG_APPLIED])); |
511 | || (!env && flag [FLAG_APPLIED])); |
479 | } |
512 | } |
|
|
513 | |
|
|
514 | MTH object *find_spell (const_utf8_string prefix) const; |
480 | |
515 | |
481 | MTH object *force_find (shstr_tmp name); |
516 | MTH object *force_find (shstr_tmp name); |
482 | MTH void force_set_timer (int duration); |
517 | MTH void force_set_timer (int duration); |
483 | MTH object *force_add (shstr_tmp name, int duration = 0); |
518 | MTH object *force_add (shstr_tmp name, int duration = 0); |
484 | |
519 | |
… | |
… | |
515 | MTH int number_of () const |
550 | MTH int number_of () const |
516 | { |
551 | { |
517 | return nrof ? nrof : 1; |
552 | return nrof ? nrof : 1; |
518 | } |
553 | } |
519 | |
554 | |
520 | MTH sint32 total_weight () const |
555 | MTH weight_t total_weight () const |
521 | { |
556 | { |
522 | return (weight + carrying) * number_of (); |
557 | return sint64 (weight + carrying) * number_of (); |
523 | } |
558 | } |
524 | |
559 | |
525 | MTH void update_weight (); |
560 | MTH void update_weight (); |
526 | |
561 | |
527 | // return the dominant material of this item, always return something |
562 | // return the dominant material of this item, always return something |
… | |
… | |
529 | { |
564 | { |
530 | return material; |
565 | return material; |
531 | } |
566 | } |
532 | |
567 | |
533 | // return the volume of this object in cm³ |
568 | // return the volume of this object in cm³ |
534 | MTH uint64 volume () const |
569 | MTH volume_t volume () const |
535 | { |
570 | { |
536 | return (uint64)total_weight () |
571 | return (volume_t)total_weight () |
537 | * 1024 // 1000 actually |
572 | * 1024 // 1000 actually |
538 | * (type == CONTAINER ? 128 : 1) |
573 | * (type == CONTAINER ? 128 : 1) |
539 | / dominant_material ()->density; // ugh, division |
574 | / dominant_material ()->density; // ugh, division |
540 | } |
575 | } |
541 | |
576 | |
… | |
… | |
574 | |
609 | |
575 | static bool msg_has_dialogue (const char *msg) { return *msg == '@'; } |
610 | static bool msg_has_dialogue (const char *msg) { return *msg == '@'; } |
576 | |
611 | |
577 | MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } |
612 | MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } |
578 | |
613 | |
579 | /* need_identify returns true if the item should be identified. This |
614 | /* need_identify returns true if the item should be identified. This |
580 | * function really should not exist - by default, any item not identified |
615 | * function really should not exist - by default, any item not identified |
581 | * should need it. |
616 | * should need it. |
582 | */ |
617 | */ |
583 | MTH bool need_identify () const; |
618 | MTH bool need_identify () const; |
584 | |
619 | |
… | |
… | |
695 | MTH void activate (); |
730 | MTH void activate (); |
696 | MTH void deactivate (); |
731 | MTH void deactivate (); |
697 | MTH void activate_recursive (); |
732 | MTH void activate_recursive (); |
698 | MTH void deactivate_recursive (); |
733 | MTH void deactivate_recursive (); |
699 | |
734 | |
|
|
735 | // prefetch and activate the surrounding area |
|
|
736 | MTH void prefetch_surrounding_maps (); |
|
|
737 | |
700 | // set the given flag on all objects in the inventory recursively |
738 | // set the given flag on all objects in the inventory recursively |
701 | MTH void set_flag_inv (int flag, int value = 1); |
739 | MTH void set_flag_inv (int flag, int value = 1); |
702 | |
740 | |
703 | void enter_exit (object *exit); // perl |
741 | void enter_exit (object *exit); // perl |
704 | MTH bool enter_map (maptile *newmap, int x, int y); |
742 | MTH bool enter_map (maptile *newmap, int x, int y); |
705 | void player_goto (const_utf8_string path, int x, int y); // only for players |
743 | void player_goto (const_utf8_string path, int x, int y); // only for players |
706 | MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0 |
744 | MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0 |
707 | |
745 | |
708 | MTH object *mark () const; |
746 | MTH object *mark () const; |
|
|
747 | MTH void splay_marked (); |
709 | |
748 | |
710 | // returns the mapspace this object is in |
749 | // returns the mapspace this object is in |
711 | mapspace &ms () const; |
750 | mapspace &ms () const; |
712 | |
751 | |
713 | // fully recursive iterator |
752 | // fully recursive iterator |
… | |
… | |
791 | * range from 0 through 7. |
830 | * range from 0 through 7. |
792 | */ |
831 | */ |
793 | MTH int anim_frames () const { return anim ().num_animations; } |
832 | MTH int anim_frames () const { return anim ().num_animations; } |
794 | MTH int anim_facings () const { return anim ().facings; } |
833 | MTH int anim_facings () const { return anim ().facings; } |
795 | |
834 | |
|
|
835 | // sets a new animation frame, if the object has animation frames, |
|
|
836 | // and updates the face |
|
|
837 | MTH void update_anim_frame (int frame); |
|
|
838 | |
796 | MTH utf8_string as_string (); |
839 | MTH utf8_string as_string (); |
797 | |
840 | |
798 | // low-level management, statistics, ... |
841 | // low-level management, statistics, ... |
799 | static uint32_t ACC (RW, object_count); |
842 | static uint32_t ACC (RW, object_count); |
800 | static uint32_t ACC (RW, free_count); |
843 | static uint32_t ACC (RW, free_count); |
… | |
… | |
872 | MTH object *instance (); |
915 | MTH object *instance (); |
873 | |
916 | |
874 | MTH void post_load_check (); // do some adjustments after parsing |
917 | MTH void post_load_check (); // do some adjustments after parsing |
875 | |
918 | |
876 | object_vector_index ACC (RW, archid); // index in archvector |
919 | object_vector_index ACC (RW, archid); // index in archvector |
877 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
920 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
878 | |
921 | |
879 | sint8 ACC (RW, max_x); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
922 | sint8 ACC (RW, max_x); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
880 | |
923 | |
881 | // support for archetype loading |
924 | // support for archetype loading |
882 | static archetype *read (object_thawer &f); |
925 | static archetype *read (object_thawer &f); |
… | |
… | |
914 | // "safely" iterate over inv in a way such that the current item is removable |
957 | // "safely" iterate over inv in a way such that the current item is removable |
915 | // quite horrible, that's why its hidden in some macro |
958 | // quite horrible, that's why its hidden in some macro |
916 | #define for_inv_removable(op,var) \ |
959 | #define for_inv_removable(op,var) \ |
917 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
960 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
918 | |
961 | |
919 | #define for_all_objects(var) \ |
962 | #define for_all_objects(var) \ |
920 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
963 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
921 | statementvar (object *, var, objects [_i]) |
964 | statementvar (object *, var, objects [_i]) |
922 | |
965 | |
923 | #define for_all_actives(var) \ |
966 | #define for_all_actives(var) \ |
924 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
967 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
925 | statementvar (object *, var, actives [_i]) |
968 | statementvar (object *, var, actives [_i]) |
926 | |
969 | |
927 | #define for_all_archetypes(var) \ |
970 | #define for_all_archetypes(var) \ |
928 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
971 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
929 | statementvar (archetype *, var, archetypes [_i]) |
972 | statementvar (archetype *, var, archetypes [_i]) |
930 | |
973 | |
931 | //+GPL |
974 | //+GPL |
932 | |
975 | |
933 | /* Used by update_object to know if the object being passed is |
976 | /* Used by update_object to know if the object being passed is |
934 | * being added or removed. |
977 | * being added or removed. |
935 | */ |
978 | */ |
936 | #define UP_OBJ_INSERT 1 |
979 | #define UP_OBJ_INSERT 1 // object was inserted |
937 | #define UP_OBJ_REMOVE 2 |
980 | #define UP_OBJ_REMOVE 2 // object was removed |
938 | #define UP_OBJ_CHANGE 3 |
981 | #define UP_OBJ_CHANGE 3 // object has changed in some unspecified way |
939 | #define UP_OBJ_FACE 4 /* Only thing that changed was the face */ |
982 | #define UP_OBJ_FACE 4 // only thing that changed was the face |
940 | |
983 | |
941 | /* These are flags passed to insert_ob_in_map and |
984 | /* These are flags passed to insert_ob_in_map and |
942 | * insert_ob_in_ob. Note that all flags may not be meaningful |
985 | * insert_ob_in_ob. Note that all flags may not be meaningful |
943 | * for both functions. |
986 | * for both functions. |
944 | * Most are fairly explanatory: |
987 | * Most are fairly explanatory: |
945 | * INS_NO_MERGE: don't try to merge inserted object with ones alrady |
988 | * INS_NO_MERGE: don't try to merge inserted object with ones alrady |
946 | * on space. |
989 | * on space. |
947 | * INS_ABOVE_FLOOR_ONLY: Put object immediatly above the floor. |
990 | * INS_ABOVE_FLOOR_ONLY: Put object immediatly above the floor. |
948 | * INS_NO_WALK_ON: Don't call check_walk_on against the |
991 | * INS_NO_WALK_ON: Don't call check_walk_on against the |
949 | * originator - saves cpu time if you know the inserted object |
992 | * originator - saves cpu time if you know the inserted object |
950 | * is not meaningful in terms of having an effect. |
993 | * is not meaningful in terms of having an effect. |
951 | * INS_ON_TOP: Always put object on top. Generally only needed when loading |
994 | * INS_ON_TOP: Always put object on top. Generally only needed when loading |
952 | * files from disk and ordering needs to be preserved. |
995 | * files from disk and ordering needs to be preserved. |
953 | * INS_BELOW_ORIGINATOR: Insert new object immediately below originator - |
996 | * INS_BELOW_ORIGINATOR: Insert new object immediately below originator - |
954 | * Use for treasure chests so the new object is the highest thing |
997 | * Use for treasure chests so the new object is the highest thing |
955 | * beneath the player, but not actually above it. Note - the |
998 | * beneath the player, but not actually above it. Note - the |
956 | * map and x,y coordinates for the object to be inserted must |
999 | * map and x,y coordinates for the object to be inserted must |
957 | * match the originator. |
1000 | * match the originator. |