mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 04:35:16 +00:00
ULTIMA8: Small const correctness improvements
This commit is contained in:
parent
8d9081e7aa
commit
3d2a2cc610
@ -120,8 +120,8 @@ bool Container::CanAddItem(Item *item, bool checkwghtvol) {
|
||||
if (volume + item->getVolume() > capacity)
|
||||
return false;
|
||||
|
||||
Item *p = getTopItem();
|
||||
Item *current = item->getTopItem();
|
||||
const Item *p = getTopItem();
|
||||
const Item *current = item->getTopItem();
|
||||
|
||||
// From outside to inside Avatar's inventory?
|
||||
if (p->getObjId() == 1 && current->getObjId() != 1) {
|
||||
@ -289,7 +289,7 @@ void Container::containerSearch(UCList *itemlist, const uint8 *loopscript,
|
||||
}
|
||||
|
||||
Item *Container::getFirstItemWithShape(uint16 shapeno, bool recurse) {
|
||||
Std::list<Item *>::iterator iter;
|
||||
Std::list<Item *>::const_iterator iter;
|
||||
for (iter = _contents.begin(); iter != _contents.end(); ++iter) {
|
||||
if ((*iter)->getShape() == shapeno)
|
||||
return *iter;
|
||||
@ -309,7 +309,7 @@ Item *Container::getFirstItemWithShape(uint16 shapeno, bool recurse) {
|
||||
}
|
||||
|
||||
void Container::getItemsWithShapeFamily(Std::vector<Item *> &itemlist, uint16 family, bool recurse) {
|
||||
Std::list<Item *>::iterator iter;
|
||||
Std::list<Item *>::const_iterator iter;
|
||||
for (iter = _contents.begin(); iter != _contents.end(); ++iter) {
|
||||
if ((*iter)->getShapeInfo()->_family == family)
|
||||
itemlist.push_back(*iter);
|
||||
|
@ -133,8 +133,8 @@ Container *Item::getParentAsContainer() const {
|
||||
return p;
|
||||
}
|
||||
|
||||
Item *Item::getTopItem() {
|
||||
Container *parentItem = getParentAsContainer();
|
||||
const Item *Item::getTopItem() const {
|
||||
const Container *parentItem = getParentAsContainer();
|
||||
|
||||
if (!parentItem) return this;
|
||||
|
||||
@ -1503,7 +1503,7 @@ int32 Item::getTargetZRelativeToAttackerZ(int32 otherz) const {
|
||||
}
|
||||
|
||||
|
||||
unsigned int Item::countNearby(uint32 shape, uint16 range) {
|
||||
unsigned int Item::countNearby(uint32 shape, uint16 range) const {
|
||||
const CurrentMap *currentmap = World::get_instance()->getCurrentMap();
|
||||
UCList itemlist(2);
|
||||
LOOPSCRIPT(script, LS_SHAPE_EQUAL(shape));
|
||||
@ -2338,12 +2338,12 @@ void Item::receiveHitCru(uint16 other, Direction dir, int damage, uint16 type) {
|
||||
}
|
||||
|
||||
|
||||
bool Item::canDrag() {
|
||||
bool Item::canDrag() const {
|
||||
const ShapeInfo *si = getShapeInfo();
|
||||
if (si->is_fixed()) return false;
|
||||
if (si->_weight == 0) return false;
|
||||
|
||||
Actor *actor = dynamic_cast<Actor *>(this);
|
||||
const Actor *actor = dynamic_cast<const Actor *>(this);
|
||||
if (actor) {
|
||||
// living actors can't be moved
|
||||
if (!actor->isDead()) return false;
|
||||
@ -2354,10 +2354,10 @@ bool Item::canDrag() {
|
||||
return true;
|
||||
}
|
||||
|
||||
int Item::getThrowRange() {
|
||||
int Item::getThrowRange() const {
|
||||
if (!canDrag()) return 0;
|
||||
|
||||
Actor *avatar = getMainActor();
|
||||
const Actor *avatar = getMainActor();
|
||||
|
||||
int range = 64 - getTotalWeight() + avatar->getStr();
|
||||
if (range < 1) range = 1;
|
||||
@ -2393,8 +2393,8 @@ static bool checkLineOfSightCollisions(
|
||||
return (blocked_time >= other_hit_time);
|
||||
}
|
||||
|
||||
bool Item::canReach(Item *other, int range,
|
||||
int32 otherX, int32 otherY, int32 otherZ) {
|
||||
bool Item::canReach(const Item *other, int range,
|
||||
int32 otherX, int32 otherY, int32 otherZ) const {
|
||||
// get location and dimensions of self and other (or their root containers)
|
||||
int32 thisX, thisY, thisZ;
|
||||
int32 thisXd, thisYd, thisZd;
|
||||
@ -2485,7 +2485,7 @@ static inline bool bothInRange(uint32 x, uint32 y, uint32 lo, uint32 hi) {
|
||||
return (x >= lo && x <= hi && y >= lo && y <= hi);
|
||||
}
|
||||
|
||||
bool Item::canMergeWith(Item *other) {
|
||||
bool Item::canMergeWith(const Item *other) const {
|
||||
// can't merge with self
|
||||
if (other->getObjId() == getObjId()) return false;
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
//! Get the top-most Container this Item is in, or the Item itself if not
|
||||
//! in a container
|
||||
Item *getTopItem();
|
||||
const Item *getTopItem() const;
|
||||
|
||||
//! Set item location. This strictly sets the location, and does not
|
||||
//! even update CurrentMap
|
||||
@ -252,7 +252,7 @@ public:
|
||||
uint16 getFamily() const;
|
||||
|
||||
//! Check if we can merge with another item.
|
||||
bool canMergeWith(Item *other);
|
||||
bool canMergeWith(const Item *other) const;
|
||||
|
||||
//! Get the open ContainerGump for this Item, if any. (NULL if not open.)
|
||||
ObjId getGump() const {
|
||||
@ -312,7 +312,7 @@ public:
|
||||
//! \param x x coordinate of other to use, If zero, use real coords.
|
||||
//! \param y y coordinate of other to use
|
||||
//! \param z z coordinate of other to use.
|
||||
bool canReach(Item *other, int range, int32 x = 0, int32 y = 0, int32 z = 0);
|
||||
bool canReach(const Item *other, int range, int32 x = 0, int32 y = 0, int32 z = 0) const;
|
||||
|
||||
//! Move the object to (x,y,z) colliding with objects in the way.
|
||||
//! \param teleport move without colliding with objects between source and
|
||||
@ -411,14 +411,14 @@ public:
|
||||
int32 getTargetZRelativeToAttackerZ(int32 attackerz) const;
|
||||
|
||||
//! count nearby objects of a given shape
|
||||
unsigned int countNearby(uint32 shape, uint16 range);
|
||||
unsigned int countNearby(uint32 shape, uint16 range) const;
|
||||
|
||||
//! can this item be dragged?
|
||||
bool canDrag();
|
||||
bool canDrag() const;
|
||||
|
||||
//! how far can this item be thrown?
|
||||
//! \return range, or 0 if item can't be thrown
|
||||
int getThrowRange();
|
||||
int getThrowRange() const;
|
||||
|
||||
//! Check this Item against the given loopscript
|
||||
//! \param script The loopscript to run
|
||||
|
Loading…
x
Reference in New Issue
Block a user