Skip to content

Commit

Permalink
Fix for issue #27
Browse files Browse the repository at this point in the history
- The rearrangement of order of logic execution resulted in an early return for all creatures under the circumstances of stepping on a square with a creature who is not a gm or ghosted, this ensures proper checks all around.

- Some logic with player::canWalkThrough needed adjustment as well, it seems the config check was only grouped with pz and level protection previously.
  • Loading branch information
Codinablack committed Dec 6, 2024
1 parent 4f326cb commit d950f2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ bool Player::canSeeGhostMode(const Creature*) const

bool Player::canWalkthrough(const Creature* creature) const
{
if (group->access || creature->isInGhostMode()) {
if (group->access || creature->isInGhostMode() || (g_config.getBoolean(ConfigManager::ALLOW_WALKTHROUGH) && creature->getPlayer() && creature-getPlayer()->isAccessPlayer())) {
return true;
}

Expand Down
8 changes: 6 additions & 2 deletions src/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,10 @@ ReturnValue Tile::queryAdd(const Creature& creature, uint32_t flags) const

if (creatures && !creatures->empty() && !hasBitSet(FLAG_IGNOREBLOCKCREATURE, flags)) {
for (const Creature* tileCreature : *creatures) {
if (!tileCreature->isInGhostMode()) {
return RETURNVALUE_NOTENOUGHROOM;
if (!tileCreature->isInGhostMode() && (tileCreature->getPlayer() && !tileCreature->getPlayer()->isAccessPlayer() )) {
if (creature.getPlayer() && !creature.getPlayer()->isAccessPlayer() && !creature.getPlayer()->canWalkthrough(tileCreature)) {
return RETURNVALUE_NOTENOUGHROOM;
}
}
}
}
Expand All @@ -515,6 +517,7 @@ ReturnValue Tile::queryAdd(const Creature& creature, uint32_t flags) const
if (ground) {
const ItemType& iiType = Item::items[ground->getID()];
if (iiType.blockSolid && (!iiType.moveable || ground->hasAttribute(ITEM_ATTRIBUTE_UNIQUEID))) {
std::cout << "BlockSolid with unique and ground return." << std::endl;
return RETURNVALUE_NOTPOSSIBLE;
}
}
Expand All @@ -523,6 +526,7 @@ ReturnValue Tile::queryAdd(const Creature& creature, uint32_t flags) const
for (const Item* item : *items) {
const ItemType& iiType = Item::items[item->getID()];
if (iiType.blockSolid && (!iiType.moveable || item->hasAttribute(ITEM_ATTRIBUTE_UNIQUEID))) {
std::cout << "BlockSolid without a ground return." << std::endl;
return RETURNVALUE_NOTPOSSIBLE;
}
}
Expand Down

0 comments on commit d950f2a

Please sign in to comment.