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.367 by root, Sun Nov 18 15:19:48 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};
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines