Skip to content

Commit

Permalink
Fix excluded zones - was checking in add/remove when excluded.
Browse files Browse the repository at this point in the history
  • Loading branch information
htwmmo committed Jan 28, 2024
1 parent d310929 commit 9cb5ad9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
36 changes: 23 additions & 13 deletions MQ2GMCheck.cpp
Expand Up @@ -21,7 +21,7 @@
#include <mq/imgui/ImGuiUtils.h>

PreSetup("MQ2GMCheck");
PLUGIN_VERSION(5.30);
PLUGIN_VERSION(5.31);

constexpr const char* PluginMsg = "\ay[\aoMQ2GMCheck\ax] ";

Expand Down Expand Up @@ -323,6 +323,23 @@ int MCEval(const char* zBuffer)
return GetIntFromString(zOutput, 0);
}

bool IsExcludedZone()
{
if (s_settings.m_ExcludeZonesEnabled.Read() && !s_settings.szExcludeZones.empty())
{
const int CurrentZone = pLocalPC ? (pLocalPC->zoneId & 0x7FFF) : 0;
if (CurrentZone > 0)
{
const std::vector<std::string> ExcludeZones = split(s_settings.szExcludeZones, '|');
if (std::find(ExcludeZones.begin(), ExcludeZones.end(), pWorldData->ZoneArray[CurrentZone]->ShortName) != ExcludeZones.end())
{
return true;
}
}
}
return false;
}

class MQ2GMCheckType* pGMCheckType = nullptr;

class MQ2GMCheckType : public MQ2Type
Expand Down Expand Up @@ -1410,18 +1427,11 @@ PLUGIN_API void OnPulse()
return true;
}), GMNames.end());
}

// Check if we are in an excluded zone
if (s_settings.m_ExcludeZonesEnabled.Read() && !s_settings.szExcludeZones.empty())
if (IsExcludedZone())
{
const int CurrentZone = pLocalPC ? (pLocalPC->zoneId & 0x7FFF) : 0;
if (CurrentZone > 0)
{
const std::vector<std::string> ExcludeZones = split(s_settings.szExcludeZones, '|');
if (std::find(ExcludeZones.begin(), ExcludeZones.end(), pWorldData->ZoneArray[CurrentZone]->ShortName) != ExcludeZones.end())
{
return;
}
}
return;
}

// Add any GMs that appeared
Expand Down Expand Up @@ -1455,7 +1465,7 @@ PLUGIN_API void OnPulse()

PLUGIN_API void OnAddSpawn(PlayerClient* pSpawn)
{
if (pLocalPC && s_settings.m_GMCheckEnabled.Read() && pSpawn && pSpawn->GM && (s_settings.m_GMCorpseEnabled.Read() || pSpawn->Type != SPAWN_CORPSE))
if (pLocalPC && s_settings.m_GMCheckEnabled.Read() && pSpawn && pSpawn->GM && (s_settings.m_GMCorpseEnabled.Read() || pSpawn->Type != SPAWN_CORPSE) && !IsExcludedZone())
{
if (pSpawn->DisplayedName[0] != '\0')
{
Expand All @@ -1466,7 +1476,7 @@ PLUGIN_API void OnAddSpawn(PlayerClient* pSpawn)

PLUGIN_API void OnRemoveSpawn(PlayerClient* pSpawn)
{
if (s_settings.m_GMCheckEnabled.Read() && !GMNames.empty() && pSpawn && pSpawn->GM)
if (s_settings.m_GMCheckEnabled.Read() && !GMNames.empty() && pSpawn && pSpawn->GM && !IsExcludedZone())
{
const size_t start_size = GMNames.size();
GMNames.erase(std::remove_if(GMNames.begin(), GMNames.end(), [pSpawn](const std::string& i)
Expand Down
8 changes: 4 additions & 4 deletions MQ2GMCheck.rc
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,30
PRODUCTVERSION 5,30
FILEVERSION 5,31
PRODUCTVERSION 5,31
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -73,11 +73,11 @@ BEGIN
#else
VALUE "FileDescription", "MQ2GMCheck Release Version"
#endif
VALUE "FileVersion", "5.30"
VALUE "FileVersion", "5.31"
VALUE "InternalName", "MQ2GMCheck.dll"
VALUE "OriginalFilename", "MQ2GMCheck.dll"
VALUE "ProductName", "MQ2GMCheck"
VALUE "ProductVersion", "5.30"
VALUE "ProductVersion", "5.31"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 9cb5ad9

Please sign in to comment.