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 (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * 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 |
9 | * 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 |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * 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 |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #ifndef OBJECT_H |
25 | #ifndef OBJECT_H |
26 | #define OBJECT_H |
26 | #define OBJECT_H |
… | |
… | |
458 | return op1->value == op2->value |
458 | return op1->value == op2->value |
459 | && op1->name == op2->name |
459 | && op1->name == op2->name |
460 | && can_merge_slow (op1, op2); |
460 | && can_merge_slow (op1, op2); |
461 | } |
461 | } |
462 | |
462 | |
463 | MTH void set_owner (object *owner); |
463 | MTH void set_owner (object_ornull *owner); |
464 | MTH void set_speed (float speed); |
464 | MTH void set_speed (float speed); |
465 | MTH void set_glow_radius (sint8 rad); |
465 | MTH void set_glow_radius (sint8 rad); |
466 | |
466 | |
467 | MTH void open_container (object *new_container); |
467 | MTH void open_container (object *new_container); |
468 | MTH void close_container () |
468 | MTH void close_container () |
… | |
… | |
521 | MTH int number_of () const |
521 | MTH int number_of () const |
522 | { |
522 | { |
523 | return nrof ? nrof : 1; |
523 | return nrof ? nrof : 1; |
524 | } |
524 | } |
525 | |
525 | |
526 | MTH sint32 total_weight () const |
526 | MTH weight_t total_weight () const |
527 | { |
527 | { |
528 | return (weight + carrying) * number_of (); |
528 | return sint64 (weight + carrying) * number_of (); |
529 | } |
529 | } |
530 | |
530 | |
531 | MTH void update_weight (); |
531 | MTH void update_weight (); |
532 | |
532 | |
533 | // return the dominant material of this item, always return something |
533 | // return the dominant material of this item, always return something |
… | |
… | |
535 | { |
535 | { |
536 | return material; |
536 | return material; |
537 | } |
537 | } |
538 | |
538 | |
539 | // return the volume of this object in cm³ |
539 | // return the volume of this object in cm³ |
540 | MTH uint64 volume () const |
540 | MTH volume_t volume () const |
541 | { |
541 | { |
542 | return (uint64)total_weight () |
542 | return (volume_t)total_weight () |
543 | * 1024 // 1000 actually |
543 | * 1024 // 1000 actually |
544 | * (type == CONTAINER ? 128 : 1) |
544 | * (type == CONTAINER ? 128 : 1) |
545 | / dominant_material ()->density; // ugh, division |
545 | / dominant_material ()->density; // ugh, division |
546 | } |
546 | } |
547 | |
547 | |