Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marksamman committed Jan 29, 2014
1 parent 69c7cfa commit 4467646
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
16 changes: 9 additions & 7 deletions src/iomapserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,24 @@ bool IOMapSerialize::loadItem(PropStream& propStream, Cylinder* parent)
return false;
}

item = g_game.transformItem(item, id);
g_game.transformItem(item, id);
} else {
std::cout << "WARNING: Unserialization error in IOMapSerialize::loadItem()" << id << std::endl;
}
} else {
//The map changed since the last save, just read the attributes
Item* dummy = Item::CreateItem(id);
if (dummy) {
dummy->unserializeAttr(propStream);
Container* container = dummy->getContainer();

// TODO: Store temporary item on stack for automatic memory management here
item = Item::CreateItem(id);
if (item) {
item->unserializeAttr(propStream);
Container* container = item->getContainer();
if (container && !loadContainer(propStream, container)) {
delete dummy;
delete item;
return false;
}

delete dummy;
delete item;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,6 @@ void Player::addManaSpent(uint64_t amount)
currReqMana = nextReqMana;
nextReqMana = vocation->getReqMana(magLevel + 1);
if (currReqMana >= nextReqMana) {
amount = 0;
return;
}
}
Expand Down
18 changes: 7 additions & 11 deletions src/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,17 +1287,13 @@ int32_t Tile::__getIndexOfThing(const Thing* thing) const
}
}

if (items) {
if (thing->getItem()) {
for (ItemVector::const_iterator it = items->getBeginDownItem(); it != items->getEndDownItem(); ++it) {
++n;
if ((*it) == thing) {
return n;
}
}
} else {
n += items->getDownItemCount();
}
if (items && thing->getItem()) {
for (ItemVector::const_iterator it = items->getBeginDownItem(); it != items->getEndDownItem(); ++it) {
++n;
if ((*it) == thing) {
return n;
}
}
}

return -1;
Expand Down

0 comments on commit 4467646

Please sign in to comment.