Skip to content

Commit

Permalink
Add ability to disable connections in zone guide (#11)
Browse files Browse the repository at this point in the history
Disables poknowledge -> airplane connection
Doesn't add new airplane connection to potranquility (requires reagent)
  • Loading branch information
brainiac committed Nov 8, 2021
1 parent cdc78cd commit fd68f4f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 6 deletions.
45 changes: 42 additions & 3 deletions EasyFindZoneConnections.cpp
Expand Up @@ -138,6 +138,7 @@ namespace YAML
data.zoneId = (EQZoneIndex)zoneId;
data.zoneIdentifier = node["identifier"].as<int>(0);
data.replace = node["replace"].as<bool>(true);
data.remove = node["remove"].as<bool>(false);
data.luaScript = node["script"].as<std::string>(std::string());
if (data.luaScript.empty())
data.luaScriptFile = node["scriptFile"].as<std::string>(std::string());
Expand Down Expand Up @@ -191,8 +192,11 @@ namespace YAML

bool ParsedFindableLocation::IsZoneConnection() const
{
if (remove)
return false;
if (zoneId != 0)
return true;

for (const auto& dest : translocatorDestinations)
{
if (dest.zoneId != 0)
Expand Down Expand Up @@ -294,7 +298,42 @@ void ZoneConnections::LoadFindableLocations()
{
EZZoneData& data = m_findableLocations[name];

data.zoneId = GetZoneID(name.c_str());
data.findableLocations = std::move(locations);

// move any "remove" entries to the removed connections list
data.removedConnections.clear();
data.findableLocations.erase(
std::remove_if(data.findableLocations.begin(), data.findableLocations.end(),
[&](const ParsedFindableLocation& pfl)
{
if (pfl.remove)
{
if (pfl.zoneId != 0)
data.removedConnections.push_back(pfl.zoneId);

return true;
}

return false;
}), data.findableLocations.end());

// Load any removed zones into the zone guide.
if (pZoneGuideWnd && !data.removedConnections.empty())
{
ZoneGuideZone* zoneGuideZone = ZoneGuideManagerClient::Instance().GetZone(data.zoneId);
if (zoneGuideZone)
{
for (int destZoneId : data.removedConnections)
{
for (ZoneGuideConnection& connection : zoneGuideZone->zoneConnections)
{
if (connection.destZoneId == destZoneId)
connection.disabled = true;
}
}
}
}
}
}
catch (const YAML::Exception& ex)
Expand Down Expand Up @@ -364,18 +403,18 @@ void ZoneConnections::CreateFindableLocations(FindableLocations& findableLocatio
}
}

const std::vector<ParsedFindableLocation>& ZoneConnections::GetFindableLocations(EQZoneIndex zoneId) const
const EZZoneData& ZoneConnections::GetZoneData(EQZoneIndex zoneId) const
{
const char* zoneName = GetShortZone(zoneId);

auto iter = m_findableLocations.find(zoneName);
if (iter == m_findableLocations.end())
{
static std::vector<ParsedFindableLocation> empty;
static EZZoneData empty;
return empty;
}

return iter->second.findableLocations;
return iter->second;
}

bool ZoneConnections::MigrateIniData()
Expand Down
8 changes: 7 additions & 1 deletion EasyFindZoneConnections.h
Expand Up @@ -31,6 +31,7 @@ struct ParsedFindableLocation
std::string luaScript;
std::string luaScriptFile;
bool replace = true;
bool remove = false;
std::vector<ParsedTranslocatorDestination> translocatorDestinations;

EQExpansionOwned requiredExpansions = (EQExpansionOwned)0;
Expand All @@ -47,8 +48,13 @@ using ParsedFindableLocationsMap = std::map<std::string, std::vector<ParsedFinda

struct EZZoneData
{
EQZoneIndex zoneId;

// our custom list of findable locations
std::vector<ParsedFindableLocation> findableLocations;

// list of removed connections
std::vector<int> removedConnections;
};

using FindableLocationsMap = std::map<std::string, EZZoneData, ci_less>;
Expand All @@ -70,7 +76,7 @@ class ZoneConnections

bool MigrateIniData();

const std::vector<ParsedFindableLocation>& GetFindableLocations(EQZoneIndex zoneId) const;
const EZZoneData& GetZoneData(EQZoneIndex zoneId) const;

void Pulse();

Expand Down
9 changes: 7 additions & 2 deletions EasyFindZonePath.cpp
Expand Up @@ -123,6 +123,8 @@ std::vector<ZonePathNode> ZonePath_GeneratePath(EQZoneIndex fromZone, EQZoneInde
break;
}

const EZZoneData& ezZoneData = g_zoneConnections->GetZoneData(currentZoneId);

if (ZoneGuideZone* currentZone = zoneMgr.GetZone(currentZoneId))
{
// Search the zone guide with modified parameters.
Expand All @@ -139,6 +141,10 @@ std::vector<ZonePathNode> ZonePath_GeneratePath(EQZoneIndex fromZone, EQZoneInde
continue;
}

// Make sure we didn't remove this connection
if (std::find(ezZoneData.removedConnections.begin(), ezZoneData.removedConnections.end(), connection.destZoneId) != ezZoneData.removedConnections.end())
continue;

// Make sure that the transfer types are supported
if (g_configuration->IsDisabledTransferType(connection.transferTypeIndex))
continue;
Expand All @@ -149,8 +155,7 @@ std::vector<ZonePathNode> ZonePath_GeneratePath(EQZoneIndex fromZone, EQZoneInde
}

// Search our own connections
const std::vector<ParsedFindableLocation>& myLocations = g_zoneConnections->GetFindableLocations(currentZoneId);
for (const ParsedFindableLocation& location : myLocations)
for (const ParsedFindableLocation& location : ezZoneData.findableLocations)
{
if (!location.IsZoneConnection())
continue;
Expand Down
3 changes: 3 additions & 0 deletions resources/EasyFind/ZoneConnections.yaml
Expand Up @@ -1100,6 +1100,9 @@ FindLocations:
switch: 25
targetZone: arena
replace: false
- type: ZoneConnection
targetZone: airplane
remove: true
potimea:
- type: Translocator
name: Herald of Druzzil Ro
Expand Down

0 comments on commit fd68f4f

Please sign in to comment.