Skip to content

Commit

Permalink
Fix possible crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
marksamman committed Jul 30, 2013
1 parent 7e185b7 commit 7e02d7f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ std::ostringstream& Container::getContentDescription(std::ostringstream& os) con
Container* evil = const_cast<Container*>(this);

for (ContainerIterator cit = evil->begin(); cit != evil->end(); ++cit) {
Container* container = (*cit)->getContainer();
Item* item = (*cit);

Container* container = item->getContainer();
if (container && container->size() != 0) {
continue;
}
Expand All @@ -199,7 +201,7 @@ std::ostringstream& Container::getContentDescription(std::ostringstream& os) con
os << ", ";
}

os << container->getNameDescription();
os << item->getNameDescription();
}

if (firstitem) {
Expand Down
6 changes: 1 addition & 5 deletions src/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,7 @@ uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* tile, bool i
eventType = MOVE_EVENT_STEP_OUT;
}

Position pos(0, 0, 0);

if (tile) {
pos = tile->getPosition();
}
Position pos = tile->getPosition();

uint32_t ret = 1;

Expand Down
4 changes: 1 addition & 3 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ void Npc::onCreatureAppear(const Creature* creature, bool isLogin)
if (m_npcEventHandler) {
m_npcEventHandler->onCreatureAppear(creature);
}
}
//only players for script events
else if (creature->getPlayer()) {
} else if (creature->getPlayer()) {
if (m_npcEventHandler) {
m_npcEventHandler->onCreatureAppear(creature);
}
Expand Down
2 changes: 1 addition & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3302,7 +3302,7 @@ Cylinder* Player::__queryDestination(int32_t& index, const Thing* thing, Item**
}

//try find an already existing item to stack with
if (tmpItem != item && tmpItem->getID() == item->getID() && tmpItem->getItemCount() < 100) {
if (tmpItem->getID() == item->getID() && tmpItem->getItemCount() < 100) {
index = n;
*destItem = tmpItem;
return tmpContainer;
Expand Down
4 changes: 3 additions & 1 deletion src/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,9 @@ bool InstantSpell::playerCastInstant(Player* player, std::string& param)
useDirection = true;
}

param = playerTarget->getName();
if (playerTarget) {
param = playerTarget->getName();
}
} else {
target = player->getAttackedCreature();

Expand Down

0 comments on commit 7e02d7f

Please sign in to comment.