Skip to content

Commit

Permalink
Merge branch 'iswatchedspawn' into 'master'
Browse files Browse the repository at this point in the history
IsWatchedSpawn - exclicitly pass size

See merge request redguides/plugins/mq2spawnmaster!3
  • Loading branch information
Sicprofundus committed Apr 19, 2023
2 parents fceae65 + 56c7428 commit baf99fa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions MQ2SpawnMaster.cpp
Expand Up @@ -209,7 +209,7 @@ template <unsigned int _Size>VOID GetLocalTimeHHMMSS(CHAR(&SysTime)[_Size])
}

// TODO: Why is Sound required to determine if something is a watched spawn?
template<unsigned int _Size>BOOL IsWatchedSpawn(PSPAWNINFO pSpawn,char(&Sound)[_Size])
bool IsWatchedSpawn(PSPAWNINFO pSpawn, char* Sound, size_t size)
{
if (pSpawn->Type==SPAWN_CORPSE)
return false;
Expand All @@ -221,18 +221,18 @@ template<unsigned int _Size>BOOL IsWatchedSpawn(PSPAWNINFO pSpawn,char(&Sound)[_
{
p++; // skip over the #
if (!strcmp(pSpawn->DisplayedName, p)) {
strcpy_s(Sound, _Size, pSearchStrings->SearchSound);
strcpy_s(Sound, size, pSearchStrings->SearchSound);
return true;
}
}
else
{
if (MaybeExactCompare(pSpawn->DisplayedName, p)) {
strcpy_s(Sound, _Size, pSearchStrings->SearchSound);
strcpy_s(Sound, size, pSearchStrings->SearchSound);
return true;
}
}
pSearchStrings++;
++pSearchStrings;
}
return false;
}
Expand Down Expand Up @@ -315,7 +315,7 @@ void WalkSpawnList()
{
while(pSpawn)
{
if(IsWatchedSpawn(pSpawn,szSound))
if(IsWatchedSpawn(pSpawn, szSound, MAX_STRING))
{
// Check IDs to see if we're already watching it
bool found = false;
Expand Down Expand Up @@ -578,7 +578,7 @@ class MQ2SpawnMasterType : public MQ2Type
if (pTarget == nullptr) return false;
Dest.Type=mq::datatypes::pBoolType;
// FIXME: Don't really want to pass a sound here
Dest.Int=IsWatchedSpawn(pTarget, DataTypeTemp);
Dest.Int=IsWatchedSpawn(pTarget, DataTypeTemp, DataTypeTemp.size());
return true;
}
return false;
Expand Down Expand Up @@ -658,7 +658,7 @@ PLUGIN_API void OnAddSpawn(PSPAWNINFO pSpawn)
if (!bSpawnMasterOn || gGameState != GAMESTATE_INGAME || !pSpawn->SpawnID)
return;
CHAR szSound[MAX_STRING] = { 0 };
if (IsWatchedSpawn(pSpawn, szSound)) {
if (IsWatchedSpawn(pSpawn, szSound, MAX_STRING)) {
AddSpawnToUpList(pSpawn,szSound);
}
}
Expand All @@ -670,7 +670,7 @@ PLUGIN_API void OnRemoveSpawn(PSPAWNINFO pSpawn)
CHAR szMsg[MAX_STRING] = {0};
CHAR szSound[MAX_STRING] = {0};

if (IsWatchedSpawn(pSpawn,szSound))
if (IsWatchedSpawn(pSpawn, szSound, MAX_STRING))
{
std::list<SPAWN_DATA>::iterator pSpawnUpList = SpawnUpList.begin();
while (pSpawnUpList!=SpawnUpList.end())
Expand Down

0 comments on commit baf99fa

Please sign in to comment.