Skip to content

Commit

Permalink
Use Pipe | to split options from spawn search (#68)
Browse files Browse the repository at this point in the history
Also fixed off-by-one error causing first spawn search argument to be
thrown away.

Usage:

  /nav spawn npc banker | dist=30
  • Loading branch information
brainiac committed Jan 25, 2019
1 parent c3c47ca commit 1c2de7e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugin/MQ2Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,21 @@ std::shared_ptr<DestinationInfo> MQ2NavigationPlugin::ParseDestinationInternal(
SEARCHSPAWN sSpawn;
ClearSearchSpawn(&sSpawn);

PCHAR text = GetNextArg(szLine, 2);
ParseSearchSpawn(text, &sSpawn);
// Find a | starting from the right side. Split the string in two if we find it.
// We'll send the first half to ParseSearchSpawn.
PCHAR text = GetNextArg(szLine, idx - 1);

std::string_view tempView{ text };
size_t pos = tempView.find_last_of("|");
if (pos != std::string_view::npos)
{
tempView = tempView.substr(0, pos);
}

CHAR szSpawnSearch[MAX_STRING];
strncpy_s(szSpawnSearch, tempView.data(), tempView.length());

ParseSearchSpawn(szSpawnSearch, &sSpawn);

if (PSPAWNINFO pSpawn = SearchThroughSpawns(&sSpawn, (PSPAWNINFO)pCharSpawn))
{
Expand Down

0 comments on commit 1c2de7e

Please sign in to comment.