From b04b46981dfd7dc638e71c01474c8c0261e8ad9a Mon Sep 17 00:00:00 2001 From: AconiteX <63141077+AconiteX@users.noreply.github.com> Date: Tue, 24 Aug 2021 09:25:24 -0400 Subject: [PATCH] Bug Fix for Cell Permissions in Space Transfers --- .../src/shared/object/CellObject.cpp | 7 - .../src/shared/object/CellPermissions.cpp | 125 ++++++++++-------- 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/engine/server/library/serverGame/src/shared/object/CellObject.cpp b/engine/server/library/serverGame/src/shared/object/CellObject.cpp index 01490960..db013595 100755 --- a/engine/server/library/serverGame/src/shared/object/CellObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/CellObject.cpp @@ -480,13 +480,6 @@ ShipObject *CellObject::getOwnerShip() bool CellObject::isAllowed(CreatureObject const &who) const { - - // always allow god - if(who.isPlayerControlled() && who.getClient()->isGod()) - { - return true; - } - if (who.getMasterId() != NetworkId::cms_invalid) { ServerObject const *master = ServerWorld::findObjectByNetworkId(who.getMasterId()); diff --git a/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp b/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp index a1309912..9d1dc0d0 100755 --- a/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp +++ b/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp @@ -569,73 +569,84 @@ bool CellPermissions::isOnList(PermissionList const &permList, std::string const bool CellPermissions::isOnList(PermissionList const &permList, CreatureObject const &who) // static { - // deal with non-players first, in which case we're looking for a raw NetworkId comparison - if(!who.isPlayerControlled()) + if(who.getClient() && who.isPlayerControlled()) { - return permList.find(who.getNetworkId().getValueString()) != permList.end(); - } - - // always consider god mode to be on the list - if(who.getClient()->isGod()) - { - return true; - } - - const int guildId = who.getGuildId(); - std::vector const & cityIds = CityInterface::getCitizenOfCityId(who.getNetworkId()); - const int cityId = cityIds.empty() ? 0 : cityIds.front(); - const uint32 faction = who.getPvpFaction(); - const uint32 stationId = NameManager::getInstance().getPlayerStationId(who.getNetworkId()); - - for (const auto & i : permList) - { - const std::string& name = i.getName(); - - if(guildId > 0 && name.rfind("guild:", 0) == 0) + // always consider god mode to be on the list + if (who.getClient()->isGod()) { - if(guildId == GuildInterface::findGuild(name.substr(6, name.length()))) + return true; + } + + const int guildId = who.getGuildId(); + std::vector const &cityIds = CityInterface::getCitizenOfCityId(who.getNetworkId()); + const int cityId = cityIds.empty() ? 0 : cityIds.front(); + const uint32 faction = who.getPvpFaction(); + const uint32 stationId = NameManager::getInstance().getPlayerStationId(who.getNetworkId()); + + for (const auto &i : permList) + { + const std::string &name = i.getName(); + + if (guildId > 0 && name.rfind("guild:", 0) == 0) + { + if (guildId == GuildInterface::findGuild(name.substr(6, name.length()))) + { + return true; + } + } + if (cityId > 0 && name.rfind("city:", 0) == 0) + { + if (cityId == CityInterface::findCityByName(name.substr(5, name.length()))) + { + return true; + } + } + if (faction != 0 && name.rfind("faction:", 0) == 0) + { + if (name.rfind("Imperial", 8) == 8) + { + if (faction == PvpData::getImperialFactionId()) + { + return true; + } + } + else if (name.rfind("Rebel", 8) == 8) + { + if (faction == PvpData::getRebelFactionId()) + { + return true; + } + } + } + if (name.rfind("account:", 0) == 0) + { + if (std::stoi(name.substr(8, name.length())) == stationId) + { + return true; + } + + } + if (name.rfind(Unicode::wideToNarrow(who.getAssignedObjectFirstName()), 0) == 0) { return true; } } - if(cityId > 0 && name.rfind("city:", 0) == 0) + } + else + { + for (PermissionList::const_iterator i = permList.begin(); i != permList.end(); ++i) { - if(cityId == CityInterface::findCityByName(name.substr(5, name.length()))) + const std::string& name = (*i).getName(); + if (name == who.getNetworkId().getValueString()) { - return true; + return true; + } + if (!_stricmp(name.c_str(), Unicode::wideToNarrow(who.getAssignedObjectFirstName()).c_str())) + { + return true; } } - if(faction != 0 && name.rfind("faction:", 0) == 0) - { - if(name.rfind("Imperial", 8) == 8) - { - if(faction == PvpData::getImperialFactionId()) - { - return true; - } - } - else if (name.rfind("Rebel", 8) == 8) - { - if(faction == PvpData::getRebelFactionId()) - { - return true; - } - } - } - if(name.rfind("account:", 0) == 0) - { - if(std::stoi(name.substr(8, name.length())) == stationId) - { - return true; - } - - } - if(name.rfind(Unicode::wideToNarrow(who.getAssignedObjectFirstName()), 0) == 0) - { - return true; - } - - } + } return false; }