ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.364 by root, Sat Sep 16 22:17:42 2017 UTC vs.
Revision 1.368 by root, Wed Dec 5 19:03:26 2018 UTC

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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 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
45uint32_t object::create_count; 46uint32_t object::create_count;
46uint32_t object::destroy_count; 47uint32_t object::destroy_count;
47 48
48//+GPL 49//+GPL
49 50
50short freearr_x[SIZEOFFREE] = { 51int freearr_x[SIZEOFFREE] = {
51 0, 52 0,
52 0, 1, 1, 1, 0, -1, -1, -1, 53 0, 1, 1, 1, 0, -1, -1, -1,
53 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 54 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1,
54 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1 55 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1
55}; 56};
56short freearr_y[SIZEOFFREE] = { 57int freearr_y[SIZEOFFREE] = {
57 0, 58 0,
58 -1, -1, 0, 1, 1, 1, 0, -1, 59 -1, -1, 0, 1, 1, 1, 0, -1,
59 -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, 60 -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2,
60 -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3 61 -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3
61}; 62};
148{ 149{
149 UUID uid; 150 UUID uid;
150 151
151 uid.seq = ++cur.seq; 152 uid.seq = ++cur.seq;
152 153
153 if (expect_false (cur.seq >= seq_next_save)) 154 if (ecb_expect_false (cur.seq >= seq_next_save))
154 { 155 {
155 seq_next_save = UUID::cur.seq + (UUID_GAP >> 1); 156 seq_next_save = UUID::cur.seq + (UUID_GAP >> 1);
156 write_uuid (UUID_GAP, false); 157 write_uuid (UUID_GAP, false);
157 } 158 }
158 159
639 * need for monsters, but doesn't hurt to do it for everything. 640 * need for monsters, but doesn't hurt to do it for everything.
640 * by doing so, when a monster is created, it has good starting 641 * by doing so, when a monster is created, it has good starting
641 * values for the body_used info, so when items are created 642 * values for the body_used info, so when items are created
642 * for it, they can be properly equipped. 643 * for it, they can be properly equipped.
643 */ 644 */
644 for (int i = NUM_BODY_LOCATIONS; i--; ) 645 for (int i = 0; i < NUM_BODY_LOCATIONS; ++i)
645 slot[i].used = slot[i].info; 646 slot[i].used = slot[i].info;
646 647
647 attachable::instantiate (); 648 attachable::instantiate ();
648} 649}
649 650
659 660
660 neu->map = map; // not copied by copy_to 661 neu->map = map; // not copied by copy_to
661 return neu; 662 return neu;
662} 663}
663 664
665// update the anhimation frame of an object, but only if it has an animation
666// assigned and the frame number if within the animation.
667void object::update_anim_frame (int frame)
668{
669 if (ecb_expect_false (!has_anim () || frame >= anim_frames ()))
670 return;
671
672 set_anim_frame (frame);
673 update_object (this, UP_OBJ_FACE);
674}
675
664/* 676/*
665 * If an object with the IS_TURNABLE() flag needs to be turned due 677 * If an object with the IS_TURNABLE() flag needs to be turned due
666 * to the closest player being on the other side, this function can 678 * to the closest player being on the other side, this function can
667 * be called to update the face variable, _and_ how it looks on the map. 679 * be called to update the face variable, _and_ how it looks on the map.
668 */ 680 */
670update_turn_face (object *op) 682update_turn_face (object *op)
671{ 683{
672 if (!op->flag [FLAG_IS_TURNABLE] || !op->arch) 684 if (!op->flag [FLAG_IS_TURNABLE] || !op->arch)
673 return; 685 return;
674 686
675 SET_ANIMATION (op, op->direction); 687 op->update_anim_frame (op->direction);
676 update_object (op, UP_OBJ_FACE);
677} 688}
678 689
679/* 690/*
680 * Updates the speed of an object. If the speed changes from 0 to another 691 * Updates the speed of an object. If the speed changes from 0 to another
681 * value, or vice versa, then add/remove the object from the active list. 692 * value, or vice versa, then add/remove the object from the active list.
691 else 702 else
692 deactivate (); 703 deactivate ();
693} 704}
694 705
695/* 706/*
696 * update_object() updates the the map. 707 * update_object() updates the map.
697 * It takes into account invisible objects (and represent squares covered 708 * It takes into account invisible objects (and represent squares covered
698 * by invisible objects by whatever is below them (unless it's another 709 * by invisible objects by whatever is below them (unless it's another
699 * invisible object, etc...) 710 * invisible object, etc...)
700 * If the object being updated is beneath a player, the look-window 711 * If the object being updated is beneath a player, the look-window
701 * of that player is updated (this might be a suboptimal way of 712 * of that player is updated (this might be a suboptimal way of
1121 below = 0; 1132 below = 0;
1122 env = 0; 1133 env = 0;
1123 1134
1124 if (pl && pl->is_player ()) 1135 if (pl && pl->is_player ())
1125 { 1136 {
1126 if (expect_false (pl->contr->combat_ob == this)) 1137 if (ecb_expect_false (pl->contr->combat_ob == this))
1127 { 1138 {
1128 pl->apply (pl->contr->combat_ob, AP_UNAPPLY | AP_IGNORE_CURSE); 1139 pl->apply (pl->contr->combat_ob, AP_UNAPPLY | AP_IGNORE_CURSE);
1129 pl->contr->combat_ob = 0; 1140 pl->contr->combat_ob = 0;
1130 if (pl->contr->ranged_ob) pl->apply (pl->contr->ranged_ob); 1141 if (pl->contr->ranged_ob) pl->apply (pl->contr->ranged_ob);
1131 } 1142 }
1132 1143
1133 if (expect_false (pl->contr->ranged_ob == this)) 1144 if (ecb_expect_false (pl->contr->ranged_ob == this))
1134 { 1145 {
1135 pl->apply (pl->contr->ranged_ob, AP_UNAPPLY | AP_IGNORE_CURSE); 1146 pl->apply (pl->contr->ranged_ob, AP_UNAPPLY | AP_IGNORE_CURSE);
1136 pl->contr->ranged_ob = 0; 1147 pl->contr->ranged_ob = 0;
1137 if (pl->contr->combat_ob) pl->apply (pl->contr->combat_ob); 1148 if (pl->contr->combat_ob) pl->apply (pl->contr->combat_ob);
1138 } 1149 }
1139 1150
1140 pl->contr->queue_stats_update (); 1151 pl->contr->queue_stats_update ();
1141 1152
1142 if (expect_false (glow_radius) && pl->is_on_map ()) 1153 if (ecb_expect_false (glow_radius) && pl->is_on_map ())
1143 update_all_los (pl->map, pl->x, pl->y); 1154 update_all_los (pl->map, pl->x, pl->y);
1144 } 1155 }
1145 } 1156 }
1146 else if (map) 1157 else if (map)
1147 { 1158 {
2523 2534
2524 for (key_value *kvp = kv.first; kvp; kvp = kvp->next) 2535 for (key_value *kvp = kv.first; kvp; kvp = kvp->next)
2525 add (kvp->key, kvp->value); 2536 add (kvp->key, kvp->value);
2526 2537
2527 reverse (); 2538 reverse ();
2539
2540 return *this;
2528} 2541}
2529 2542
2530object::depth_iterator::depth_iterator (object *container) 2543object::depth_iterator::depth_iterator (object *container)
2531: iterator_base (container) 2544: iterator_base (container)
2532{ 2545{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines